A modern, full-stack web application that converts Word documents (.doc, .docx) to PDF format with a beautiful user interface and robust backend processing.
- Fast and reliable Word to PDF conversion
- Drag and drop file upload interface
- Real-time conversion progress tracking
- Automatic file download after conversion
- Responsive design for all devices
- Secure file handling with automatic cleanup
- Support for both .doc and .docx formats
- File size validation (up to 10MB)
- Modern UI with smooth animations
- Toast notifications for user feedback
- Rate limiting for API protection
- CORS and security middleware
- Batch file conversion (planned)
- User authentication (planned)
- Conversion history (planned)
- React 18 - Modern React with hooks and functional components
- Vite - Fast build tool and development server
- Tailwind CSS - Utility-first CSS framework
- Axios - HTTP client for API requests
- React Hot Toast - Beautiful toast notifications
- React Icons - Comprehensive icon library
- Node.js - JavaScript runtime environment
- Express.js - Web application framework
- Multer - Middleware for handling file uploads
- Mammoth - Library for extracting text from Word documents
- PDF-lib - Library for creating PDF documents
- Helmet - Security middleware for Express
- CORS - Cross-Origin Resource Sharing middleware
- Express Rate Limit - Rate limiting middleware
Important
Ensure you have the following installed on your system:
- Node.js: v22.17.0 or higher
- npm: v10.9.2 or higher
You can check your versions by running:
node -v
npm -vgit clone https://github.com/nayandas69/word-to-pdf-converter.git
cd word-to-pdf-converterInstall dependencies for all packages (root, backend, and frontend):
npm run install-depsThis command will:
- Install root dependencies
- Install backend dependencies
- Install frontend dependencies
The backend uses environment variables for configuration. The default .env file is already configured for development:
# Server Configuration
PORT=3000
NODE_ENV=development
# CORS Configuration
FRONTEND_URL=http://localhost:5173
# File Upload Configuration
MAX_FILE_SIZE=10485760
ALLOWED_FILE_TYPES=.doc,.docx
# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100Note
For production deployment, update the FRONTEND_URL to match your deployed frontend URL.
Run both frontend and backend development servers concurrently:
npm run devThis will start:
- Backend server: http://localhost:3000
- Frontend server: http://localhost:5173
Start only the backend server:
npm run serverStart only the frontend client:
npm run clientGET /api/healthReturns the API health status and version information.
POST /api/convertRequest:
- Method:
POST - Content-Type:
multipart/form-data - Body: Form data with
filefield containing the Word document
Response:
- Success: PDF file download
- Error: JSON error message
Example using curl:
curl -X POST \
http://localhost:3000/api/convert \
-H 'Content-Type: multipart/form-data' \
-F 'file=@/path/to/your/document.docx'The frontend can be deployed to any static hosting service:
-
Build the frontend:
cd frontend npm run build -
Deploy the
distfolder to your hosting service (Netlify, Vercel, etc.)
Important
Vercel supports Node.js serverless functions. The backend is configured for Vercel deployment.
-
Install Vercel CLI:
npm install -g vercel
-
Deploy to Vercel:
cd backend vercel -
Set Environment Variables in Vercel dashboard:
NODE_ENV=productionFRONTEND_URL=https://your-frontend-domain.comMAX_FILE_SIZE=10485760ALLOWED_FILE_TYPES=.doc,.docx
Caution
When deploying to Vercel, be aware of the following limitations:
- Serverless functions have a 10-second execution timeout
- File uploads are limited to 4.5MB for Hobby plan
- Temporary file storage is limited in serverless environment
For better file handling capabilities, consider these alternatives:
- Railway: Supports persistent storage and longer execution times
- Render: Free tier with good Node.js support
- Heroku: Reliable platform with file system support
- DigitalOcean App Platform: Scalable with persistent storage
- Helmet.js - Sets various HTTP headers for security
- CORS - Configured for specific frontend origin
- Rate Limiting - Prevents API abuse
- File Validation - Validates file type, size, and content
- Automatic Cleanup - Removes uploaded files after processing
- Input Sanitization - Validates and sanitizes all inputs
The application includes comprehensive error handling:
{
"success": false,
"message": "Error description",
"error": "ERROR_CODE",
"timestamp": "2024-01-01T00:00:00.000Z"
}UPLOAD_ERROR- File upload failedVALIDATION_ERROR- File validation failedCONVERSION_ERROR- PDF conversion failedFILE_TOO_LARGE- File exceeds size limitINVALID_FILE_TYPE- Unsupported file format
- File Size Limits - Prevents large file uploads
- Automatic Cleanup - Removes temporary files
- Rate Limiting - Prevents server overload
- Optimized Builds - Minified production builds
- Lazy Loading - Components loaded on demand
- Image Optimization - Optimized assets
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Contact the maintainer: Nayan Das
- docx-pdf - Core conversion library
- React - Frontend framework
- Tailwind CSS - CSS framework
- Express.js - Backend framework
Made with 💔 by Nayan Das