Skip to content

A lightweight Flask-based REST API that converts raw HTML into downloadable PDF files — perfect for generating invoices, reports, certificates, and frontend-rendered documents.

Notifications You must be signed in to change notification settings

Talabov/Html-To-pdf-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧾 HTML to PDF Converter API


🚀 Need a ready-to-deploy version?

Includes Docker, setup guide, sample responses, and full API structure.

👉 Buy it on Gumroad


This Flask-based API accepts raw HTML and returns a generated PDF. Useful for invoices, reports, or documents rendered from frontend.


✅ Features

  • 🔁 Converts raw HTML to downloadable PDF
  • 📬 POST endpoint: /convert-html
  • 🧻 Uses pdfkit (requires wkhtmltopdf)
  • 🐳 Dockerfile includes wkhtmltopdf
  • 🧱 Minimal and fast

🚀 Endpoint

POST /convert-html

Request Body:

{
  "html": "<h1>Hello PDF</h1><p>This is generated from HTML</p>"
}

Success Response:

  • Returns binary PDF file with headers:
Content-Disposition: attachment; filename=converted.pdf
Content-Type: application/pdf

⛔ Error Responses

{ "error": "No HTML content provided" }

⚙️ Requirements

pip install -r requirements.txt

Also install wkhtmltopdf on your system if running locally:

sudo apt install wkhtmltopdf

🐳 Docker

Dockerfile installs wkhtmltopdf and runs the server:

docker build -t html-to-pdf-api .
docker run -p 5000:5000 html-to-pdf-api

🧪 Screenshots

Postman examples in /screens.


💼 Production Version

Packaged and ready for deployment. Clean modular code + Docker + error handling:

👉 Buy on Gumroad


📬 Contact


Need this in another language (Node.js, Go)? Custom implementation available — just ask.

About

A lightweight Flask-based REST API that converts raw HTML into downloadable PDF files — perfect for generating invoices, reports, certificates, and frontend-rendered documents.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published