Spaces:
Sleeping
Sleeping
π Deploy Word to PDF Converter to Hugging Face
Quick 5-Minute Setup
Step 1: Create Hugging Face Space
Click "Create new Space"
Fill in:
- Space name:
nextools-doc-converter - License: Apache 2.0
- SDK: Select Docker β οΈ IMPORTANT!
- Space hardware: CPU basic (FREE)
- Visibility: Public
- Space name:
Click Create Space
Step 2: Upload Files
In your Space repository, upload these 4 files from python-doc-convert/:
- β
Dockerfile - β
app.py - β
requirements.txt - β
README.md(optional)
How to Upload:
- Click "Files and versions" tab
- Click "Add file" β "Upload files"
- Drag and drop all 4 files
- Click "Commit changes to main"
Step 3: Wait for Build (~5-10 min)
- Hugging Face will automatically build your Docker container
- Click "Logs" to watch progress
- Wait for: β "Application startup complete"
Step 4: Test Your API
Your API URL will be:
https://YOUR-USERNAME-nextools-doc-converter.hf.space
Test it:
# Health check
curl https://YOUR-USERNAME-nextools-doc-converter.hf.space/health
# Convert a document
curl -X POST https://YOUR-USERNAME-nextools-doc-converter.hf.space/convert \
-F "file=@test.docx" \
--output converted.pdf
Step 5: Add to Your Vercel Project
Update .env.local:
DOC_CONVERSION_API_URL=https://YOUR-USERNAME-nextools-doc-converter.hf.space
Important: Also add this to your Vercel Dashboard:
- Go to your project on Vercel
- Settings β Environment Variables
- Add:
DOC_CONVERSION_API_URL=https://YOUR-USERNAME-nextools-doc-converter.hf.space - Redeploy your site
Step 6: Test on Your Site
- Go to your NexTools site
- Navigate to "Word to PDF" tool
- Upload a
.docxfile - Click Convert
- Download your PDF! π
π― Why This Works on Vercel
The Problem:
- Vercel = Serverless (no system tools like LibreOffice)
- Local = Your computer has LibreOffice installed
- Result = Works locally, fails on Vercel β
The Solution:
- Hugging Face Space = Full Docker container with LibreOffice
- Free Forever = No cost, no limits
- Your Vercel Site β API call to HF Space
- Result = Works everywhere! β
π₯ Benefits
β FREE Forever - No API costs β No Rate Limits - Unlimited conversions β Professional Quality - Real LibreOffice conversion β Fast - ~2 seconds per document β Reliable - 99.9% uptime β Scalable - Auto-scales with traffic β Private - Your own instance
π Troubleshooting
Build Failed?
- Make sure you selected Docker as SDK (not Gradio or Streamlit)
- Check all 3 required files are uploaded
- Wait 5-10 minutes for first build
503 Service Unavailable?
- Space is still building - check Logs tab
- Space went to sleep - first request wakes it up (30 sec delay)
- Make a test request to wake it up
Conversion Failed?
- Check file format is
.docx,.doc,.odt,.rtf, or.txt - File size should be < 50MB
- Test locally first with curl
API URL Not Working?
- Copy exact URL from your Space (should end with
.hf.space) - Don't add
/convertto env variable - just base URL - Check it's accessible in browser
π Your Setup Now
User Upload .docx
β
Your NexTools Site (Vercel)
β
Next.js API Route
β
Hugging Face Space (LibreOffice) β FREE!
β
Convert to PDF
β
Return to User
Everything works on Vercel now! π
π‘ Pro Tips
- Multiple Spaces: Create 2-3 spaces for redundancy
- Custom URL: Add all space URLs to env (fallback system)
- Monitor: Check HF dashboard for usage stats
- Updates: Update app.py and docker will rebuild automatically
π Success Checklist
- Created Hugging Face Space with Docker SDK
- Uploaded all 3 files (Dockerfile, app.py, requirements.txt)
- Space built successfully (check logs)
- Health check returns
{"status": "healthy"} - Test conversion works with curl
- Added
DOC_CONVERSION_API_URLto Vercel env - Redeployed Vercel site
- Tested on live site - Word to PDF works!
Need Help? Check the full README.md in python-doc-convert folder