HTML to PDF in Python

One requests.post. Works the same in Django, Flask, FastAPI, Celery workers, and Jupyter notebooks.

HTML PDF PNG JPEG URL
No credit card required · 500 free renders/month

The whole integration

Nothing to compile, nothing to apt-get. res.content is the PDF.

render.py
import os
import requests

res = requests.post(
    "https://api.filecook.com/render/pdf",
    headers={"Authorization": f"Bearer {os.environ['FILECOOK_API_KEY']}"},
    json={
        "html": "<h1>Invoice #1042</h1>",
        "options": {"format": "A4", "margin": "12mm"},
    },
    timeout=30,
)
res.raise_for_status()

with open("invoice.pdf", "wb") as f:
    f.write(res.content)

Against the usual Python options

The two common libraries each have a sharp edge. wkhtmltopdf wraps a long-unmaintained WebKit build, so CSS Grid, Flexbox gaps, and modern selectors silently misrender. WeasyPrint is actively maintained and produces lovely output, but it implements its own layout engine — it does not execute JavaScript, so anything rendered client-side is simply absent.

  • Filecook runs current Chromium, so charting libraries that draw in the browser work as-is
  • No system packages to pin in your Dockerfile or CI image
  • Identical output from a developer laptop, a CI runner, and production

Django and Celery

Render a template with render_to_string, hand the resulting HTML to the API, and return a FileResponse. For bulk exports, do the same inside a Celery task — the API is queue-backed on our side too, so fanning out a few hundred concurrent renders is expected rather than exceptional.

Frequently asked questions

Does this work with Django templates?
Yes. Render the template to a string with render_to_string and post that string as the html field. Nothing about your template layer changes.
Is there a Python SDK?
The API is a plain HTTPS POST, so requests or httpx is all you need. A typed SDK is on the roadmap.
Do you support modern CSS like Grid and Flexbox?
Yes. Filecook renders on the latest Chromium, so CSS Grid, Flexbox, custom properties, and modern selectors all behave exactly as they do in Chrome. If it looks right in your browser, it looks right in the PDF.
Do you store the documents you render?
No. Rendering happens in an isolated memory enclave and the output is discarded as soon as it has been returned to your request. Nothing is written to disk and nothing is retained.
Is there a free tier?
Yes — 500 renders a month, free forever, with no credit card required. That covers the playground, the full API, and both PDF and image output.

Keep reading

Ready to start cooking?

500 renders a month, free forever. No credit card, no sales call.