Skip to content

tazeetech/excel-to-pdf-api

Repository files navigation

Excel to PDF Converter

A modern, free web tool to convert Excel files (.xls, .xlsx) to PDF format using LibreOffice headless mode.

Features

  • ✅ Convert Excel files (.xlsx, .xls) to PDF
  • LibreOffice ONLY - No other conversion dependencies
  • ✅ Beautiful Bootstrap 5 UI with modern design
  • ✅ Drag & drop file upload
  • ✅ Progress bar with real-time updates
  • ✅ Secure file handling with automatic cleanup
  • ✅ Docker containerization
  • ✅ Ready for Render.com and Railway.app deployment
  • ✅ File size validation (50MB limit)
  • ✅ Responsive design

Quick Start

Using Docker (Recommended)

# Build and run
docker-compose up --build

# Access at http://localhost:5000

Local Development

Prerequisites:

  • Python 3.11+
  • LibreOffice installed
# Install dependencies
pip install -r requirements.txt

# Run the application
python app.py

# Access at http://localhost:5000

API Endpoints

POST /convert

Convert an uploaded Excel file to PDF.

Request:

  • Method: POST
  • Content-Type: multipart/form-data
  • Body: Excel file (field name: file)

Response:

  • Success: PDF file download
  • Error: JSON error message

Example using curl:

curl -X POST -F "file=@example.xlsx" http://localhost:5000/convert -o output.pdf

GET /health

Health check endpoint.

Response:

{
  "status": "OK",
  "service": "Excel to PDF Converter",
  "libreoffice_available": true,
  "timestamp": "2024-01-01T00:00:00.000000"
}

GET /info

Get service information and capabilities.

Deployment

Render.com

  1. Connect your Git repository
  2. Render will automatically detect the Dockerfile
  3. The service will be deployed using Docker
  4. LibreOffice will be available in the container

Railway.app

  1. Connect your Git repository
  2. Select Dockerfile as the build method
  3. Deploy automatically

Project Structure

excel-to-pdf/
├── app.py                 # Flask backend
├── requirements.txt       # Python dependencies
├── Dockerfile            # Docker configuration
├── docker-compose.yml    # Docker Compose for development
├── README.md             # This file
├── templates/
│   └── index.html        # Frontend HTML
└── static/
    ├── css/
    │   └── style.css     # Custom styles
    └── js/
        └── script.js     # Frontend JavaScript

Error Handling

  • Invalid file format: "Please upload a valid Excel file (.xls or .xlsx)."
  • File too large: "File size must be less than 50MB."
  • Conversion failure: "Failed to convert file. Please try again."

Security

  • File type validation
  • File size limits (50MB)
  • Secure filename handling
  • Temporary file cleanup
  • Non-root user in Docker container

License

MIT License

Support

For issues and questions, please check the logs or create an issue in the repository.

About

excel to pdf api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published