Skip to content
Python

Convert HTML to PDF in Python, with a real browser engine.

wkhtmltopdf and its descendants stalled on an old WebKit build years ago — flexbox, grid and modern web fonts are hit or miss. The Python client renders in current Chromium instead, so what you see in a browser is what comes back as a PDF.

pip install pagemint

from pagemint import Pagemint

pm = Pagemint(api_key=os.environ["PAGEMINT_KEY"])
pdf = pm.render(html="<h1>Hello</h1>")

Why not wkhtmltopdf, weasyprint, or xhtml2pdf

These are real tools with real users, and for a simple document they're often enough. Where they tend to fall over: CSS Grid, modern flexbox edge cases, @font-face with variable fonts, and JavaScript-rendered content — all of which a real Chromium instance just handles, because that's the engine most of your users' browsers are running anyway.

A Django view

def invoice_pdf(request, invoice_id):
    invoice = Invoice.objects.get(id=invoice_id)
    pdf = pm.render(template="invoice", data=invoice.to_dict())
    return JsonResponse({"url": pdf.url})

On Node.js instead?

Same API, same rendering engine — the Node client covers the same ground.