Skip to content

WeasyPrint alternative

WeasyPrint Alternative for Python Teams That Need JavaScript and Chrome Accurate PDFs

WeasyPrint is a good library right up to the day a template needs JavaScript. Charts come out as empty boxes, a layout that is perfect in Chrome shifts by a few pixels, and the Pango and font packages you installed to make it run become part of every Docker image you ship. A WeasyPrint alternative that renders in real Chromium fixes all three without making you run a browser yourself. SitePDF takes your HTML or URL in one HTTP request and returns the PDF, and keeps a dated copy of every render if you ask it to.

  • PDF and archive in one call
  • Plans from $49 a month
  • Your HTML stays yours

Short answer

People search for a WeasyPrint alternative when a document that looks right in Chrome comes out wrong from WeasyPrint. The usual cause is structural: WeasyPrint is its own layout engine and runs no JavaScript, so Chart.js, Plotly, ApexCharts and anything a framework draws after page load never appear. The alternatives are Playwright or Puppeteer on your own servers, or a rendering API such as SitePDF that runs Chromium for you. If your templates are static HTML and CSS, keep WeasyPrint. If they contain scripts or must match what a customer sees in Chrome, use a Chromium renderer.

Written and fact checked by the SitePDF team.

WeasyPrint and the alternatives, compared on what decides the choice

WeasyPrint, Playwright and Puppeteer are free open source projects. The SitePDF API figures come from our pricing page. The row that surprises most Python teams is the infrastructure one.

WeasyPrint Playwright or Puppeteer (self-host) SitePDF API
Rendering engine Its own layout engine, built for print CSS Real Chromium Managed Chromium
Runs JavaScript No, by design Yes Yes
Charts from Chart.js or Plotly Empty box unless pre-rendered to an image Yes, once the page settles Yes, with a wait condition
Matches what Chrome shows Close for simple CSS, differs on complex layouts Yes Yes
Print CSS (@page, running headers) Strong. Its best feature. Good, header and footer templates Good, header and footer options
Install and runtime pip install plus Pango and font libraries Node or Python, Chromium download, shared memory and sandbox flags in Docker None, it is an HTTP call
Cost Free Free plus server and engineering time API from $49/mo ($288 billed yearly) for 10,000 renders, $99/mo for 50,000
Dated archive of every render No No Yes. archive=true, 90 days to 7 years by tier

WeasyPrint is the better tool when the document is static HTML and the job is precise print layout: running page numbers, footnotes, CSS paged media. This page is for the case where the template has outgrown it.

When to keep WeasyPrint

WeasyPrint earns its place. It installs with pip, renders a page in milliseconds rather than seconds, and implements a good deal of the CSS paged media specification that Chromium handles less gracefully: named pages, running elements, footnotes and cross references. A report built around @page margin boxes and a real table of contents is a job WeasyPrint does well. It can also write PDF/A and PDF/UA variants, which matters if an auditor asks for them. If your template is plain HTML and CSS generated on the server and nothing on the page needs a script, there is no reason to leave. Read the WeasyPrint documentation for the current CSS support list before you decide anything.

The three things that push teams off WeasyPrint

JavaScript. The project states it plainly: no user interaction, no JavaScript, no live rendering. Any chart, map or component that draws itself after load renders as whatever was in the raw HTML, usually an empty container. We walk through the failure and the four ways to work around it in why WeasyPrint charts do not render. Pre-rendering charts to SVG in matplotlib is a sound fix when the chart only has to exist in the PDF. It is a poor one when the same visualization already lives in your web app and you would be maintaining it twice.

Fidelity to the browser. Product, finance and legal teams review the web page in Chrome and expect the PDF to match. WeasyPrint is a separate layout engine, so complex flexbox and grid layouts, web fonts and sticky or transformed elements can land a few pixels or a whole line off. Each mismatch is a ticket that says "the PDF looks different", and each one costs an engineer an afternoon.

Operations. WeasyPrint needs Pango and a set of system font libraries. That is easy on a laptop and a recurring chore in slim containers, Alpine images, AWS Lambda and CI runners, where a missing font package silently changes the typeface of every invoice.

Playwright and Puppeteer, and what running them really means

The obvious fix is Playwright. Its page.pdf() prints through Chromium, so scripts run and layout matches Chrome. It works well, and it moves the problem rather than removing it. You now ship a browser in your image, size memory for each concurrent page, handle the case where Chromium crashes mid-render, wait correctly for fonts and charts, and patch the browser as security fixes land. At a few documents an hour that is a small tax. At thousands a day it is a service you own. We priced that trade in HTML to PDF library vs API, and the Puppeteer alternative page covers the Node side of the same decision.

How SitePDF fits a Python codebase

You keep the template you already have, whether it is a Jinja2 file, a Django template or a page your app already serves. Instead of calling HTML(string=html).write_pdf(), you post the HTML or URL to the render endpoint and get a PDF URL back. Charts render because the page runs in Chromium; you pass a wait_for selector so the print starts only once the chart is drawn. Nothing about your Python deployment changes, and Pango can come out of your Dockerfile. Django specifics are on the HTML to PDF in Django page, and the wider library comparison is on Python PDF generation.

Each render can also be archived. If you generate invoices, contracts or statements, you get a timestamped copy of exactly what was rendered, retained from 90 days on the Starter API tier to 7 years on Enterprise. WeasyPrint has no equivalent, so teams usually bolt on object storage and a retention job. Plan details are on the pricing page.

A practical way to decide

Open your three most complex templates and ask two questions. Does any element depend on a script to appear? Would a reviewer comparing the PDF to Chrome notice a difference? If both answers are no, WeasyPrint is the right tool and the cheapest one. If either is yes, run the same template through the API and compare the output side by side. Our PDF API pricing comparison lays out what other rendering services charge for the same job so you can price it before you commit.

From Python: send the same HTML you gave WeasyPrint and get Chromium output, charts included.
import requests

resp = requests.post(
    'https://api.sitepdf.com/v1/render',
    headers={'Authorization': f'Bearer {SITEPDF_KEY}'},
    data={
        'html': render_template('report.html', data=data),
        'format': 'A4',
        'wait_for': '#revenue-chart',  # selector that exists once the chart is drawn
        'archive': 'true',          # keep a dated copy of this render
    },
    timeout=60,
)
pdf_url = resp.json()['pdf_url']

This is the documented API call shape. Full request and response walkthrough.

Questions about this job

What is the best alternative to WeasyPrint?
It depends on the template. If it needs JavaScript or must match Chrome, use a Chromium renderer: Playwright or Puppeteer if you will run the browser yourself, or a rendering API like SitePDF if you would rather make one HTTP call. If the document is static and print focused, stay with WeasyPrint. Match the engine to the template rather than switching by default.
Does WeasyPrint support JavaScript?
No. WeasyPrint is not built on a browser engine and runs no scripts, so charts and any content a script draws after load do not appear. Pre-render charts to SVG or PNG on the server, or render the page in a real browser such as Chromium before converting. This is a design choice documented by the project, not a bug.
Is WeasyPrint faster than Puppeteer?
Usually yes for simple documents. WeasyPrint renders in milliseconds and needs no browser start, while Chromium pays a launch and page load cost measured in seconds. The gap closes when you keep a browser warm, and it is irrelevant if the document needs JavaScript, because WeasyPrint cannot produce the right output at any speed.
Is WeasyPrint free for commercial use?
Yes. WeasyPrint is open source under a permissive BSD license, so you can use it in commercial products at no license cost. The real costs are engineering time, the system libraries it depends on, and any work spent around its limits such as pre-rendering charts. Check the project license page for the current terms.
Can I replace WeasyPrint without running my own browser?
Yes. A hosted renderer runs Chromium for you, so you post HTML or a URL and receive a PDF with no Node, Chromium or Pango to install. SitePDF also archives a dated copy of each render. You keep your existing templates and change only the call that produces the PDF.
How much does a WeasyPrint alternative cost?
Self-hosted Playwright or Puppeteer is free to license but costs server capacity and engineering time. SitePDF API plans start at $49 a month for 10,000 renders, $99 for 50,000 and $299 for 250,000, with yearly billing saving about half on the smaller tiers. Compare it against the hours you spend on rendering problems today.

Index

More PDF and archiving tools

Get started

Render and archive with one API call

A pixel perfect PDF and a dated copy of the page from the same request. Plans from $49 a month, half price billed yearly.

HTML to PDF, in your browser

Buy the plan