Your WeasyPrint PDF looks fine until you compare it side-by-side with the browser. Flexbox items overlap, grid areas collapse, and page breaks land in the middle of table rows. The CSS renders without throwing an error, so the breakage is silent.
The problem is what happens at the edges: advanced grid features still render incorrectly, page breaks inside flex or grid containers slice content unpredictably, and flex wrapping can diverge from browser behavior.
The failures surface as stderr warnings, not raised exceptions. Your CI pipeline passes, your tests pass, and your users receive a PDF that looks like a print stylesheet from 2005. GitHub issue #613 has been open since 2013 for flex-flow: row wrapping incorrectly on A4 paper, where browsers display the same markup correctly [1]. Issue #324 started with a user asking about switching from wkhtmltopdf and checking flexbox support [2].
There is no JavaScript execution by design. Chart.js, D3, React-rendered content, and any client-side math are impossible. Teams still design templates with interactive charts first, then discover the ceiling only at build time.
The rendering engine is single-core CPU-bound Python drawing work. A WeasyPrint user rendering a 15-page HTML document on Django reported the process consuming 70% to 80% of CPU [3]. For a 1500-page document with roughly 420 PNGs, write_pdf took about 85 seconds, with 50 to 55 seconds spent in RasterImage.get_x_object alone [4]. A parallel image-processing patch cut that to 48 seconds, but the actual drawing stayed single-core [4].
System dependencies block serverless deployment. Pango, Cairo, and GDK-PixBuf must be present on the host. Many serverless platforms do not include them in their Python runtimes. On macOS, multiprocessing with forked workers triggers CoreFoundation crashes with "You MUST exec()" errors, requiring spawn workarounds [5]. Maintainers of a WeasyPrint-based PDF API have been asked whether the service can handle parallel requests, since WeasyPrint is CPU bound and would block the FastAPI event loop while a PDF is being processed [6].
#613: flex-flow: row wraps incorrectly on A4 paper. Any browser correctly displays the markup with three items in a row; WeasyPrint cannot [1].#324: A user looking to switch from wkhtmltopdf asked about flexbox support before moving [2].#2982: Image-heavy documents spend most of their time in sequential PNG stream building, not parallelizable layout work [4].Warnings in stderr mean your deployment scripts, your pytest suite, and your GitHub Actions workflow all green-light visually broken PDFs. You only discover the problem when a customer emails a screenshot or when your finance team asks why the invoice total overlaps the line items.
Yet teams repeatedly design templates with JS charts first, assuming they can strip the interactivity later. Static fallbacks for Chart.js or D3 require pre-rendering the chart as an image, which introduces another dependency and another point of failure.
MarkupGo runs the same HTML through its rendering pipeline, then returns the PDF. The /pdf endpoint generates a PDF from a URL, HTML, or a template [7].
To get bytes back instead of a task object, append /buffer to the endpoint URL [7]. Authentication uses an x-api-key header [7]. You can set expiresInSeconds for automatic cleanup, ranging from 60 seconds to 90 days [8]. For reusable templates, pass a template ID with a context object, and include JavaScript or CSS libraries in the template configuration [8]. Options like waitDelay, waitForExpression, and extraHttpHeaders let you control how the render waits before capture [8].
import requests
def render_pdf(html_string, api_key):
response = requests.post(
"https://markupgo.com/api/v1/pdf",
headers={
"Content-Type": "application/json",
"x-api-key": api_key
},
json={
"source": {
"type": "html",
"data": html_string
},
"options": {
# see Markupgo's API reference for margin, format, printBackground
},
"expiration": {
"expiresInSeconds": 3600
}
}
)
response.raise_for_status()
return response.content
# Usage
pdf_bytes = render_pdf(
"<html>...</html>",
api_key="YOUR_API_KEY"
)
with open("output.pdf", "wb") as f:
f.write(pdf_bytes)
For templates you render repeatedly, store the HTML and CSS in the MarkupGo dashboard, then reference by ID:
json={
"source": {
"type": "template",
"data": {
"id": "YOUR_TEMPLATE_ID",
"context": {
"invoice_number": "INV-2024-001",
"total": 1499.00
}
}
}
}
Templates can include JavaScript libraries for charts and CSS libraries for styling [8].
The free tier includes 100 credits per month with no credit card required.
Keep WeasyPrint for simple letterhead, single-column text documents, or regulated environments that ban external API calls.
Switch when your template uses flexbox or grid for invoices, reports, or certificates. Switch when you need Chart.js, D3, or any client-rendered visualization. Switch when you deploy to serverless and cannot install Pango, Cairo, and GDK-PixBuf. Switch when your Django box is already at 70% CPU from rendering alone [3]. Switch when your CI pipeline should fail on visual regressions, not stderr warnings you have trained yourself to ignore.
Audit one production PDF against its browser preview. Open the WeasyPrint stderr output and check for warnings you have been filtering out. Then swap the render call for the MarkupGo /buffer endpoint using the Python snippet above. The 100 free credits let you validate your existing templates without changing your HTML or CSS [7].