Python PDF API
Generate PDFs in Python with one request
No WeasyPrint install, no wkhtmltopdf binary, no system libraries to chase down in a Docker image. From Flask, FastAPI, or Django, a single request turns HTML into a PDF with real fonts and proper page breaks.
FastAPI or any Python backend
Use httpx or requests. The response content is the PDF. The same call drops into a Flask route or a Django view.
Python
import httpx, os
async def render(html: str) -> bytes:
async with httpx.AsyncClient() as client:
r = await client.post(
"https://api.pdfpipe.xyz/v1/pdf",
headers={"Authorization": f"Bearer {os.environ['PDFPIPE_API_KEY']}"},
json={"html": html, "options": {"format": "A4"}},
)
r.raise_for_status()
return r.content # the PDF bytesWhy a Python PDF API
- No native libraries
- WeasyPrint and wkhtmltopdf pull in system dependencies that break in slim containers. An API has none.
- Modern CSS
- Flexbox, grid, and web fonts render correctly, which library renderers often miss.
- Async friendly
- Works naturally with httpx and async frameworks like FastAPI.
Fits common Python stacks
- Flask PDF generation from a route with requests.
- FastAPI PDF generation with async httpx.
- Django generate PDF from a view, no extra system packages.
- Optional Python SDK with render, merge, batch, and templates.
Frequently asked
How do I generate a PDF in Python?
POST your HTML to /v1/pdf with a bearer token using httpx or requests. The response content is the PDF. No WeasyPrint or wkhtmltopdf needed.
Does it work with Flask, FastAPI, and Django?
Yes. It is a plain HTTP call, so it drops into a Flask route, a FastAPI async endpoint, or a Django view without extra system libraries.
Is there a Python SDK?
Yes. The official Python SDK covers render, merge, batch, and templates, though a direct request works too.
Why not WeasyPrint?
WeasyPrint is great but installs system dependencies and misses some modern CSS and JavaScript-rendered content. An API uses a browser engine and has nothing to install.
Related guides and APIs
These pages cover related search intents. Pick the one that matches what you are building.
100 free documents a month, flat pricing after that, and a live playground you can try without signing up.