You build a report template in HTML. It looks right in the browser: the layout holds, the webfont loads, the Chart.js graph draws. Then you run it through WeasyPrint and the PDF comes back with a blank space where the chart should be. No exception, no warning, just a hole in the page.

That is not a bug you can fix. WeasyPrint does not execute JavaScript, so anything drawn or injected client-side simply does not exist as far as its renderer is concerned. This post walks through where the Python PDF stack falls short and the API route around it; it originally appeared on the HTML to Image blog as WeasyPrint Alternative: HTML to PDF in Python.

Where WeasyPrint stops

WeasyPrint has earned its popularity. It is pure Python, it takes CSS paged media seriously and for static, document-shaped HTML it produces clean output. If your templates are plain markup with print styles, it does the job.

The problems start when your HTML behaves like the modern web: