Skip to content

Python PDFKit With wkhtmltopdf or a Rendering API and What a Year Costs

Python pdfkit only calls the wkhtmltopdf binary, which is archived and prints with an old engine. At 10,000 documents a month an API costs about $588 in year one against about $2,880.

Live demo

Runs in your browser. Nothing is uploaded. One PDF free to try, then a plan.

Your PDF is downloading. That was the free one. The Starter plan converts as many as you need, for $49 a month or $288 a year, half price.

See the plan

SitePDF is an HTML to PDF API, and this article is for a Python team that uses pdfkit today or is about to, and wants to know what it costs to keep it running. The short answer is that Python pdfkit is a thin wrapper around the wkhtmltopdf binary, that the binary is archived and prints with an old browser engine, and that at 10,000 documents a month an API costs about $588 in year one against about $2,880 for running it yourself.

The short answer

The pdfkit package does very little by itself. It builds a command line, calls wkhtmltopdf and hands you back the file. Every rendering decision belongs to wkhtmltopdf, so the useful question is not whether pdfkit is good but whether wkhtmltopdf is still the right engine for your documents.

For a plain table invoice with a logo, it still works and costs nothing in licenses. For a layout that uses flexbox, grid, newer CSS or a script that draws a total, it prints something different from your web page, and the project that could fix that stopped taking changes. That archive date is stated on the wkhtmltopdf status page.

What breaks when you use pdfkit in production?

ProblemWhat you seeUsual fix
The binary must exist on the serverAn error that wkhtmltopdf is not found after a deployInstall it in the image and pin the version
Old WebKit engineFlexbox and grid layouts collapse, newer CSS is ignoredRewrite the print view with tables and floats
Scripts run slowly or not at allCharts and client side totals are missingPre render the numbers on the server, drop the chart
Fonts differ from the browserWrong typeface or missing glyphs on the PDFInstall fonts in the image and test each one
Remote content is fetched by the binaryUser supplied HTML can make the server call internal addressesDisable local file access and sanitize input
No upstream fixesA rendering bug stays a bugWork around it or change engine

The last two rows matter most for a product that prints customer controlled content. A renderer that fetches addresses from inside your network is a security task, not only a layout one, and our article on HTML to PDF API security lists what to check. For how the old engine behaves in containers, see wkhtmltopdf in Docker and what it costs. Ruby teams on the same engine can read the WickedPDF cost article.

What does a year of pdfkit cost against an API?

These are planning assumptions, not measurements. Take a Python SaaS that sends 10,000 invoices and statements a month and uses Django or Flask. The comparison below uses an hourly rate of $75 and counts one render per document.

Cost lineKeep pdfkitSitePDF Starter API
Setup and print template12 hours, $9004 hours to swap the call, $300
Server share or container$15 a month, $180$0
Upkeep, fonts, crashes, workarounds2 hours a month, $1,800$0
Service fee$0$288 billed yearly
Year one$2,880$588

Your numbers will differ. If your documents are simple and your engineer spends no time on the converter, the left column falls toward $180 and pdfkit wins on price. The right column is fixed by the pricing page: Starter API is $49 a month for 10,000 renders, Growth is $99 a month for 50,000 and Scale is $299 a month for 250,000.

How do you move from pdfkit to an API?

You keep the HTML. The part that changes is the single line that calls the converter. Instead of pdfkit.from_string(html, False), post the same string and read back the PDF address.

import os, requests

resp = requests.post(
    "https://api.sitepdf.com/v1/render",
    headers={"Authorization": f"Bearer {os.environ['SITEPDF_KEY']}"},
    json={"html": html, "format": "Letter", "archive": True},
    timeout=60,
)
pdf_url = resp.json()["pdf_url"]

Options you passed to pdfkit map to render fields. Page size is format, and running headers and page numbers are header_html and footer_html, which the page numbers and footers page explains. With archive set, the render is also stored with a SHA-256 hash, useful when a customer disputes an invoice, and the invoice PDF archive page shows how to fetch it later.

Which Python route fits which team?

The Python PDF generation page compares all six routes. In short, WeasyPrint suits static documents and is covered in its own cost article. ReportLab suits documents drawn from data, not HTML. Playwright gives real Chromium at the price of operating a browser. A rendering API gives the same Chromium output with no server to run, and the wkhtmltopdf alternative page lists the migration steps in more detail.

Who this is for and who it is not for

It is for Python teams that print invoices, statements or reports from a product and have outgrown what wkhtmltopdf draws. It is not for teams that cannot send document content to an outside service, or ones with a few static documents a month, where pdfkit on a spare server is cheaper. The general sums are in library versus API.

What to do this week

Take your three most complex documents and print them with pdfkit and with the API side by side. If the PDFs match your web view in both, stay where you are. If you find a table rewrite or a missing chart, post one real invoice to SitePDF and compare. Plans are on the pricing page.

Frequently asked questions

What is the best alternative to Python pdfkit?

For static documents, WeasyPrint is the usual free choice. For layouts that match the browser, Playwright or a hosted Chromium API print closer. The right pick depends on whether you want to operate a browser or send an HTTP call.

Is wkhtmltopdf still maintained?

No. The repository was archived on 2 January 2023, so bugs and security issues are not fixed upstream. It still runs, but new projects usually choose a Chromium based renderer instead.

Why does pdfkit need wkhtmltopdf installed?

Because pdfkit is only a wrapper. It builds a command line and calls the wkhtmltopdf binary, which does the real rendering. If the binary is missing or the wrong version, pdfkit fails even when your Python code is fine.

How much does an HTML to PDF API cost for Python?

SitePDF Starter API is $49 a month for 10,000 renders, or $288 billed yearly. Growth is $99 a month for 50,000 renders and Scale is $299 a month for 250,000. Count one render per document.

Written by the team behind SitePDF, an HTML to PDF API that archives every page it renders. The in-browser converter is free to try, and API plans start at $49 a month, half price billed yearly.

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