Skip to content

A wkhtmltopdf alternative: headless Chromium over an API

wkhtmltopdf's own status page and repository tell you where the project stands. This guide maps its common options to a headless Chromium PDF API and shows the same job as code you can run.

In one sentence

A migration guide that maps common wkhtmltopdf command-line options to a headless Chromium PDF API and shows the same job as cURL, Node and Python code.

Key facts

  • wkhtmltopdf's GitHub repository shows it archived by the owner on Jan 2, 2023 and read-only; its status page says QtWebKit was deprecated in 2015 and removed in 2016 (checked 2026-10-09).
  • The API renders with headless Chromium, so current CSS such as flexbox and grid and your page's JavaScript are supported.
  • Print styles are the default here, while wkhtmltopdf uses screen styles unless asked; send media screen to keep the old behaviour.

Why people are moving

  • The wkhtmltopdf GitHub repository shows "archived by the owner on Jan 2, 2023" and is read-only. Source: github.com/wkhtmltopdf/wkhtmltopdf, checked 2026-10-09.
  • Its status page says QtWebKit, the engine it uses, was deprecated in 2015 and removed in 2016, and tells you not to use wkhtmltopdf with untrusted HTML. Source: wkhtmltopdf.org/status.html, checked 2026-10-09.
  • This service renders with headless Chromium, which supports current CSS such as flexbox and grid layout, and runs your page's JavaScript.

None of this means your existing PDFs are wrong. It is a reason to plan a move, and to test your own templates before you do.

Option mapping

wkhtmltopdf options are from its usage page (wkhtmltopdf.org/usage/wkhtmltopdf.txt, checked 2026-10-09). The API options go inside options of POST /v1/render.

wkhtmltopdfAPI optionNote
-s, --page-size A4format: "A4"Also width and height for custom sizes (wkhtmltopdf: --page-width, --page-height).
-O Landscapelandscape: true
-T / -B / -L / -Rmargin: { top, bottom, left, right }wkhtmltopdf lists a default of 10 mm for left and right. Ours defaults to 10 mm on all four sides.
--print-media-typemedia: "print"wkhtmltopdf uses screen styles unless you pass this flag. Ours prints with print styles by default, so send media: "screen" to keep the wkhtmltopdf behaviour.
--background / --no-backgroundprint_background: true | falseOn by default in both.
--javascript-delay <ms>delay_ms (up to 10000)Also wait_until and wait_for_selector. These are not exact equivalents.
--header-html, --footer-htmldisplay_header_footer: true, header_template, footer_templateTemplates are HTML strings. Page numbers use spans with the classes pageNumber and totalPages. Leave room in the margins.
--zoom <float>scaleThe closest equivalent. Check the result against your layout.
--disable-smart-shrinkingno direct equivalentCompare your output and adjust the CSS.

Before and after

A typical wkhtmltopdf call:

wkhtmltopdf
wkhtmltopdf --page-size A4 --orientation Portrait \
  --margin-top 20mm --margin-bottom 20mm --margin-left 15mm --margin-right 15mm \
  report.html report.pdf

The same job against the API. Set AIIPWORLD_API_KEY to a key from your dashboard. The cURL version needs jq.

import { readFile, writeFile } from "node:fs/promises";

const API = "https://api.aiipworld.com";
const headers = { Authorization: `Bearer ${process.env.AIIPWORLD_API_KEY}`, "Content-Type": "application/json" };

const html = await readFile("report.html", "utf8");
const submit = await fetch(`${API}/v1/render`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    html,
    output: "pdf",
    options: {
        "format": "A4",
        "landscape": false,
        "media": "screen",
        "margin": { "top": "20mm", "bottom": "20mm", "left": "15mm", "right": "15mm" }
      },
  }),
});
const { job_id } = await submit.json();

let job;
let delay = 1000; // poll calls count toward the per-minute limit, so back off
do {
  await new Promise((r) => setTimeout(r, delay));
  delay = Math.min(delay * 1.5, 5000);
  job = await (await fetch(`${API}/v1/jobs/${job_id}`, { headers })).json();
} while (job.status === "queued" || job.status === "running");

if (job.status !== "succeeded") throw new Error(`${job.status}: ${job.error}`);
const pdf = await (await fetch(job.download_url)).arrayBuffer();
await writeFile("report.pdf", Buffer.from(pdf));

Headers and footers: add display_header_footer: true with header_template and footer_template, as in the PDF API example. The sample below was made that way.

Example output

PDF with header and page number footer (page 1)
Output of the request in this guide. Generated by this site's own engine. Page 1 shown. Open the PDF (or select the picture) for the full document.

Things to check when you switch

  • Relative files. The API loads public http and https addresses only, not files on your disk. Inline images and CSS with data URLs, use absolute https URLs, or send base_url.
  • Fonts. Fonts on your own server are not on ours. The render server has the Noto and Liberation families and colour emoji; for others use @font-face with a public or data URL.
  • Page breaks. Use break-inside: avoid on rows or blocks you do not want split. A table header set to display: table-header-group repeats on each page; we checked that with a multi-page table.
  • Layout differences. A different engine means small differences. Compare real documents side by side.
  • Where the HTML goes. It is sent to our servers and deleted after the retention time of your plan. Keep documents that cannot leave your network on your own infrastructure.

Prefer to run it yourself? Headless Chromium driven by Playwright or Puppeteer is the common self-hosted route. Our HTML to PDF tool lets you try the output without an account.

Choosing a wkhtmltopdf alternative

There are three ways to replace wkhtmltopdf. Pick the one that matches how much control you need and how much you want to run yourself.

  • Run headless Chromium yourself with Playwright or Puppeteer. You control the browser, fonts and timeouts, and you look after them too.
  • Use a hosted API such as this one. Each job runs headless Chromium in a fresh browser context inside a resource-limited worker container, with a hard timeout.
  • Use another hosted PDF API, such as DocRaptor. It also runs JavaScript and works asynchronously, so compare the details that matter to you.

Is wkhtmltopdf safe to use?

The project's own status page answers part of this. It says the engine it uses, Qt WebKit, was deprecated in 2015 and removed in 2016. It also advises against using wkhtmltopdf with untrusted HTML (wkhtmltopdf.org/status.html, checked 2026-10-09).

If your application renders HTML from users, that advice applies to you. Moving to headless Chromium also means leaving the archived wkhtmltopdf project.

Migration steps

Move one template at a time. Small steps make differences easier to trace.

  • List the wkhtmltopdf options your scripts use, and map each one with the option mapping table above.
  • Render one real template through both tools and save the two PDFs side by side.
  • Compare page breaks, margins, fonts and images. Fix layout differences in your CSS first.
  • Test large HTML through the API. The free web tool accepts up to 256 KB of HTML per conversion.
  • Send the same HTML as a job, then poll GET /v1/jobs/{id} until the status is succeeded and download the file.
  • When the output matches what you need, change your code and remove the old command.

What changes when you switch

Some defaults are different. Check these before you compare results.

  • PDFs use print styles by default. Set media to screen if your page should print as it looks on screen.
  • The page is printed as A4 with the default margin on all sides, unless you set format or margin.
  • JavaScript runs by default. For pages that build themselves after load, use wait_until, wait_for_selector or delay_ms.
  • Each job gets a fresh browser context, so cookies and cache are not shared between jobs. Send headers with the request when a site needs them.
  • Credits for failed and timed-out jobs are returned, and jobs are asynchronous, so your code should poll for the result.

Running headless Chromium yourself

Self-hosting is a valid choice if your documents must stay on your own machines. The engine behind this service is the same kind of tool: headless Chromium driven by Playwright.

A self-hosted setup needs your own timeout for each job, your own clean-up of temporary files, and the fonts you install.

Where a wkhtmltopdf replacement fits in your code

A wkhtmltopdf replacement changes how your code runs more than it changes your HTML. Instead of calling a local binary, your code sends one POST request to /v1/render and then checks the job until the PDF is ready.

If you searched for wkhtmltopdf chromium, you want a newer engine for the same kind of PDF. This API prints with Chromium, not Qt WebKit. Templates still need a check, as covered above, because fonts and print styles can differ.

Python HTML to PDF without wkhtmltopdf

Python wrappers such as pdfkit call the wkhtmltopdf program under the hood. To do python html to pdf without wkhtmltopdf, send the HTML to the API with an HTTP library: POST it to /v1/render with output set to pdf, poll the job, then download the file from download_url.

Questions

Is wkhtmltopdf still maintained?

Its GitHub repository was archived by the owner on 2 January 2023 and is read-only (checked 2026-10-09 on github.com/wkhtmltopdf/wkhtmltopdf). Its status page also says it uses Qt WebKit, which was deprecated in 2015 and removed in 2016, and advises against using it with untrusted HTML (wkhtmltopdf.org/status.html, checked 2026-10-09).

Will my existing HTML render the same?

Not necessarily. The rendering engine is different, so layouts can shift. Run your real templates through both and compare before you switch, and fix differences in your CSS.

How do I convert a local HTML file with relative images and CSS?

The API loads public http and https addresses only, not files on your machine. Inline images and styles with data URLs, point them at absolute https URLs, or send base_url so relative paths resolve against a public site.

Are my fonts available?

Fonts installed on your own server are not on ours. The render server has the Noto and Liberation font families and colour emoji. For other fonts, load them with @font-face from a public URL or a data URL.

Do I have to send my HTML to a third party?

With the API, yes: the HTML is sent to our servers and deleted after the retention period of your plan. If that is not acceptable for your documents, running headless Chromium yourself is the alternative.

How do page numbers work?

Pass footer_template HTML containing spans with the classes pageNumber and totalPages, set display_header_footer to true and leave room in the top and bottom margins.

Is wkhtmltopdf safe?

The project's status page advises against using wkhtmltopdf with untrusted HTML. It also says its engine, Qt WebKit, was removed in 2016 (wkhtmltopdf.org/status.html, checked 2026-10-09). If you render HTML from other people, move to a current engine.

Can I use Puppeteer or Playwright myself instead?

Yes. You can run headless Chromium yourself with Puppeteer or Playwright. You then control the browser and where it runs, and you handle timeouts, clean-up and fonts yourself. The API takes that work off your hands.

How do I keep the same margins and page size?

Keep format set to A4, which is the default, or set it to the size you used before. Set margin on each side to the values from your old command. print_background is on by default, so backgrounds print unless you turn it off. Check the option mapping table above for the rest.

Is wkhtmltopdf deprecated?

The project is archived. Its GitHub repository was archived by the owner on 2 January 2023 and is read-only (source: github.com/wkhtmltopdf/wkhtmltopdf, checked 2026-10-09). Its status page says the engine it uses, Qt WebKit, was deprecated in 2015 and removed in 2016 (source: wkhtmltopdf.org/status.html, checked 2026-10-09).

Related tools