Menu

1 / 2

How I built a PDF Generator API with FastAPI and ReportLab

DEV Community·Ing. Pablo Cueto·6 months ago
#jr8OWwVR
#python#fastapi#api#pdfs#rapidapi
Reading 0:00
15s threshold

The problem

Almost every SaaS app needs to generate PDFs at some point — invoices,

reports, receipts. Most developers end up wrestling with Puppeteer,

wkhtmltopdf, or heavy libraries that are painful to deploy.

I decided to build a simple REST API that does it with a single POST request.

The stack

FastAPI — for the REST endpoints

ReportLab — for PDF generation in Python

Docker + Render — for deployment

RapidAPI — for monetization

How it works

Send a JSON payload, get a PDF back:

import requests

response = requests . post ( " https://pdf-generator-api-1fx5.onrender.com/generate/invoice " , headers = { " X-API-Key " : " your-key " }, json = { " invoice_number " : " INV-2025-001 " , " company " : { " name " : " Acme Corp " , " email " : " [email protected] " }, " client " : { " name " : " John Doe " , " email " : " [email protected] " }, " items " : [ { " description " : " Web Development " , " quantity " : 10 , " unit_price " : 150 } ], " tax_rate " : 16 } )

with open ( " invoice.pdf " , " wb " )…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.