Stack · Python
Generate PDFs in Python
Python PDF tooling usually means wrestling with system dependencies — WeasyPrint's native libraries, or the now-archived wkhtmltopdf binary.
Skip all of it: the official client is standard-library only. Send HTML or a URL, get bytes back, write the file.
01Call it from Python
from rendral import RenderClient
client = RenderClient(os.environ["PDF_API_KEY"])
pdf = client.pdf(html="<h1>Invoice</h1>", options={"pageNumbers": True})
with open("invoice.pdf", "wb") as f:
f.write(pdf)Frequently asked
Do I need WeasyPrint or wkhtmltopdf?
No. Rendering happens on our headless-Chrome infrastructure; the Python client has zero dependencies beyond the standard library.
Does it work in serverless Python (Lambda)?
Yes — there's no browser to package, so the client works in constrained environments where headless Chrome can't.
How are errors surfaced?
The client raises a RenderError carrying the API's status, machine-readable code, and request ID.
Related
Reports PDF API
Turn dashboards, analytics and charts into shareable PDF reports via API.
Compare vs PDFCrowd
How PDFCrowd and Rendral differ on pricing, features, and setup.
PDFs in Vercel
A step-by-step guide to generating PDFs from Vercel.
A free tier, 20 endpoints, and SDKs for Node and Python.