A modern, user-friendly web application to merge multiple PDF files into a single document. Features a clean drag-and-drop interface with file reordering capabilities.
- π Drag & Drop Upload: Simply drag PDF files onto the upload area
- π Reorder Files: Drag files in the list to change merge order
- π± Responsive Design: Works on desktop, tablet, and mobile devices
- π Secure: Files are processed server-side and deleted immediately after download
- π¨ Fast: Efficient PDF processing with no watermarks
- π 100% Free: No registration, no hidden fees
- Backend: Python 3.8+, Flask
- PDF Processing: PyPDF
- Frontend: HTML5, CSS3, Vanilla JavaScript
- Production Server: Gunicorn (Linux/Mac) or Waitress (Windows)
mergepdf/
βββ app.py # Flask application
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ templates/
β βββ index.html # Main HTML template
βββ static/
βββ css/
β βββ style.css # Stylesheet
βββ js/
βββ app.js # Frontend JavaScript
- Python 3.8 or higher
- pip (Python package manager)
-
Clone or navigate to the project directory:
cd mergepdf -
Create a virtual environment (recommended):
# Windows python -m venv venv venv\Scripts\activate # Linux/Mac python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the development server:
python app.py
-
Open your browser and navigate to:
http://localhost:5000
-
Create a
render.yamlfile in your project root:services: - type: web name: pdf-merger env: python buildCommand: pip install -r requirements.txt startCommand: gunicorn app:app envVars: - key: PYTHON_VERSION value: 3.11.0
-
Push to GitHub and connect to Render
-
Create a new Web Service and select your repository
-
Push your code to GitHub
-
Go to Railway and create a new project
-
Select "Deploy from GitHub repo"
-
Railway will auto-detect Python and deploy
-
Create a
Procfile:web: gunicorn app:app -
Create a
runtime.txt:python-3.11.0 -
Deploy using Heroku CLI:
heroku create your-app-name git push heroku main
-
SSH into your server
-
Install Python and pip:
sudo apt update sudo apt install python3 python3-pip python3-venv nginx
-
Clone your project:
git clone https://github.com/yourusername/pdf-merger.git cd pdf-merger -
Set up virtual environment:
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt -
Create a systemd service (
/etc/systemd/system/pdfmerger.service):[Unit] Description=PDF Merger Web App After=network.target [Service] User=www-data WorkingDirectory=/path/to/pdf-merger Environment="PATH=/path/to/pdf-merger/venv/bin" ExecStart=/path/to/pdf-merger/venv/bin/gunicorn --workers 3 --bind unix:pdfmerger.sock -m 007 app:app [Install] WantedBy=multi-user.target
-
Configure Nginx (
/etc/nginx/sites-available/pdfmerger):server { listen 80; server_name yourdomain.com; client_max_body_size 50M; location / { include proxy_params; proxy_pass http://unix:/path/to/pdf-merger/pdfmerger.sock; } }
-
Enable and start services:
sudo ln -s /etc/nginx/sites-available/pdfmerger /etc/nginx/sites-enabled sudo systemctl start pdfmerger sudo systemctl enable pdfmerger sudo systemctl restart nginx
-
Create a
Dockerfile:FROM python:3.11-slim WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . EXPOSE 5000 CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
-
Create a
.dockerignore:__pycache__ *.pyc venv .git *.pdf -
Build and run:
docker build -t pdf-merger . docker run -p 5000:5000 pdf-merger
| Variable | Description | Default |
|---|---|---|
MAX_CONTENT_LENGTH |
Maximum upload size in bytes | 50MB |
SECRET_KEY |
Flask secret key (set in production) | None |
-
Set a secret key in production:
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'your-secret-key')
-
Use HTTPS in production (configure via reverse proxy)
-
Set appropriate CORS headers if needed
-
Consider rate limiting for public deployments
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Main web interface |
| POST | /merge |
Upload and merge PDF files |
| GET | /download/<session_id>/<filename> |
Download merged PDF |
Request: multipart/form-data with files[] containing PDF files
Response:
{
"success": true,
"message": "PDFs merged successfully!",
"session_id": "uuid",
"filename": "merged_20241210_123456.pdf",
"total_pages": 10,
"file_size": 524288,
"files_merged": 3
}- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a Pull Request
MIT License - feel free to use this project for personal or commercial purposes.
If you encounter any issues or have suggestions, please open an issue on GitHub.
Made with β€οΈ by [Your Name]