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
render.py
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.
Start rendering in minutes.
A free tier, five endpoints, and SDKs for Node and Python.