Migrations

Move from wkhtmltopdf

Use with your agent

Read https://thirds.ai/docs/wkhtmltopdf and map my wkhtmltopdf command to a thirds.ai request and plan checks for layout changes

You can keep your HTML and data when you move PDF creation to thirds.ai. Replace the local command with a request to POST /v1/pdf. Start with one document type, such as an invoice, and compare the PDF before you move the next one.

Expect some layout differences. thirds.ai uses a pinned Chromium version, while wkhtmltopdf uses Qt WebKit. The engines can wrap text, size fonts, and break pages differently, even when the options match.

Map the options you use

Use this table to translate your current command. Option names come from the wkhtmltopdf command reference. Request fields come from the thirds.ai API contract.

wkhtmltopdf option or inputthirds.ai request
HTML fileRead the file in your app and send its text as html.
--page-size A4pdf.format: "A4"
--page-width and --page-heightpdf.width and pdf.height, both with units. Omit format.
--orientation Landscapepdf.landscape: true
--margin-top, --margin-right, --margin-bottom, --margin-leftThe matching sides in pdf.margins
--background or --no-backgroundpdf.print_background: true or false
--zoomStart with pdf.scale, from 0.1 to 2, then compare the layout.
--header-html or --footer-htmlInline HTML in pdf.header_template or pdf.footer_template, with display_header_footer: true
[page] and [toPage]Empty spans with pageNumber and totalPages classes
--disable-javascriptjavascript.mode: "disabled", the default
--enable-javascriptjavascript.mode: "enabled", plus the ready marker
--javascript-delay or --window-statusReplace the wait with the ready marker.

Review differences before switching

Your app must send HTML text. The API does not accept a source page URL or log in to your site. It also cannot read your local files, take cookies, or accept arbitrary asset request headers. Load private data in your app before you send the HTML. Use permitted public or inline assets and keep credentials out of the source.

PDF output uses print styles. Check any old screen-only styles and remove @media print rules that hide content you need. Set page dimensions and margins in the request. The default API margins are zero, so set the margins from your old command yourself.

Give header and footer templates their own styles. They do not inherit body styles, and their scripts do not run. The PDF layout guide has a two-page request with page numbers. The Playwright PDF reference explains Chromium's print behaviour.

Check unsupported options before you switch. This API has no wkhtmltopdf smart-shrinking switch, outline or table-of-contents option, PDF form option, or multi-input command. It also has no exposed DPI, grayscale, custom proxy, or load-error-ignore option. Put the layout and content you need into one HTML document. If your workflow relies on one of these options, check that you can produce an acceptable PDF before you move it.

Try a fixed-size document

Start with this request to compare page size, margins, and scale. It uses no remote assets or JavaScript:

json request POST /v1/pdf
{
  "html": "<!doctype html><html lang='en'><head><meta charset='utf-8'><style>body{margin:0;font:16px/1.5 sans-serif}h1{color:#0a46ff}table{width:100%;border-collapse:collapse}td{padding:12px;border-bottom:1px solid #ddd}</style></head><body><h1>Invoice 1042</h1><table><tr><td>Monthly report</td><td>USD 120.00</td></tr></table><p>Total: USD 120.00</p></body></html>",
  "pdf": {
    "width": "180mm",
    "height": "240mm",
    "landscape": true,
    "margins": { "top": "8mm", "right": "8mm", "bottom": "8mm", "left": "8mm" },
    "print_background": true,
    "scale": 0.8
  }
}

The repository's renderer visual cases use these options and the guides' page-number pattern. They check expected page sizes and counts for invoices, long content, headers, footers, fonts, and JavaScript. Those tests cover their own sample documents. You still need to compare your templates.

Compare, switch, and recover

  1. Save sample inputs and PDFs from your current renderer. Include long names, empty fields, many rows, and every language and font you use.
  2. Send the same content to thirds.ai. Compare page count, paper size, line wraps, totals, logos, headers, and footer numbers. Check the first and last page of long documents.
  3. Adjust the HTML or options where the PDF differs. Save a version of the template you accept and keep its sample data.
  4. Move one document type to thirds.ai. Store each job ID beside your business record. Add retry and download handling before you move more work.
  5. Keep your previous renderer and accepted template version available during the move. If the new layout fails your checks, stop new requests for that document type and return to the previous renderer. Check thirds.ai jobs that are still running before you create replacements, so customers do not get duplicate documents.

Each successful comparison render uses the normal credit price. Keep the downloaded comparison files in your own storage. Move the next document type after the first one passes your checks.