“Printing failed (-32000)” in Gotenberg
Chromium, which Gotenberg drives to turn HTML, web pages and Markdown into PDF, could not print the page. It happens with very long pages, with too little memory, and with headers or footers that are large or load files from elsewhere. Keep headers and footers self-contained, print long documents in parts and merge them, and give the container more memory.
Gotenberg 8.25 and later, and Gotenberg 9, answer 400:
Chromium failed to print the PDF; this usually happens when the page is too largeEarlier versions answer 500, and their log says:
print to PDF: Printing failed (-32000)Chromium could not print the page.
- Very long pages. Hundreds or thousands of pages in one go can make Chromium’s printing fail; Gotenberg’s documentation calls it a known Chromium problem.
- Too little memory. If the page’s renderer runs out of memory, the print fails with it.
- Large headers and footers. A header or footer with large inline images, or a whole CSS framework, can make the print fail.
- Files loaded from headers and footers. Chromium does not load style sheets, fonts or scripts in headers and footers; a
<link>to one there, such as a web font, can fail the print.
Two neighbouring errors have causes of their own: a page range past the last page, or written wrongly, and print settings outside what Chromium accepts, such as margins larger than the page. Gotenberg answers each with a 400 that names it.
Smaller pieces, more room.
1. Keep headers and footers self-contained: styles in a <style> element, pictures as data URLs, and fonts installed in the image, not loaded from elsewhere. A footer that prints:
<html>
<head>
<style>
body { margin: 0 16px; font: 9px sans-serif; color: #555; }
</style>
</head>
<body>
<p>Page <span class="pageNumber"></span> of <span class="totalPages"></span></p>
</body>
</html>curl --request POST http://localhost:3000/forms/chromium/convert/html --form files=@index.html --form files=@footer.html -o report.pdf2. Print a long document in parts, then merge the parts. In Gotenberg 8, with nativePageRanges and the merge route:
curl --request POST http://localhost:3000/forms/chromium/convert/html --form files=@index.html --form nativePageRanges=1-200 -o part-1.pdfcurl --request POST http://localhost:3000/forms/chromium/convert/html --form files=@index.html --form nativePageRanges=201-400 -o part-2.pdfcurl --request POST http://localhost:3000/forms/pdfengines/merge --form files=@part-1.pdf --form files=@part-2.pdf -o report.pdfIn Gotenberg 9, the field is nativePages and the route /forms/pdf/merge:
curl --request POST http://localhost:3000/forms/chromium/convert/html --form files=@index.html --form nativePages=1-200 -o part-1.pdfcurl --request POST http://localhost:3000/forms/chromium/convert/html --form files=@index.html --form nativePages=201-400 -o part-2.pdfcurl --request POST http://localhost:3000/forms/pdf/merge --form files=@part-1.pdf --form files=@part-2.pdf -o report.pdfSplitting the content itself into several pages, each converted on its own, works the same way and needs less memory still.
3. Give the container more memory. From Gotenberg 9.6, --chromium-max-memory also sets a limit: past it, Gotenberg restarts Chromium and answers 503, before the whole container runs out of memory.
Pages laid out without a browser.
Marqius Kern answers Gotenberg’s Chromium routes and lays the pages out itself, with no browser inside. In our test, a 411-page register in a container with 1 GB of memory: Gotenberg 8 and 9 answered “Chromium failed to print the PDF”, and Marqius Kern printed all 411 pages in under a second. A footer that loads a web font, which failed the print in Gotenberg 8, printed in Marqius Kern too.
docker run --rm -d --name kern -p 3000:3000 marqius/kerncurl --retry 10 --retry-delay 1 --retry-all-errors http://localhost:3000/healthcurl --request POST http://localhost:3000/forms/chromium/convert/html --form files=@index.html --form files=@footer.html -o report.pdfPages that need a real browser, such as canvas drawings and charts that measure the page as they draw, print without those parts: keep Gotenberg for those.
Free for open source. Licensed for business.
Personal, teaching and open-source use is free with a Community licence, including open-source projects’ CI runs and documentation builds.
- Get your free key on marqius.com/licence/marqius-kern, then sign in with Google.
- Tick “I’ll use Marqius Kern only for personal, teaching or open-source work”.
- Get my free key, then Copy key.
- Set it as the variable
MARQIUS_LICENCEon your server.
Anything done by or for a business, including internal tools and client work, needs a paid licence. See the plans and prices.
Questions
What does “Printing failed (-32000)” mean?
Chromium, which Gotenberg drives, could not print the page to PDF. -32000 is Chromium’s code for a general failure; Gotenberg 8.25 and later answer it as 400 “Chromium failed to print the PDF”.
Why does it happen with long documents?
Printing hundreds or thousands of pages in one go can exhaust Chromium’s memory. Print the document in parts with page ranges and merge them, or split its content.
Why does my header or footer cause it?
Chromium does not load style sheets, fonts or scripts in headers and footers, and very large ones fail to print. Keep them small: inline styles, pictures as data URLs, fonts installed in the image.
Does more memory fix it?
Often, when the renderer ran out of memory, but not always: very long pages can fail with memory to spare. Printing in parts is the dependable fix.
Does Marqius Kern use Chromium?
No. It answers Gotenberg’s Chromium routes and lays the pages out itself, with no browser inside. Pages that need a real browser, such as canvas charts, print without those parts.
Change one line. Keep your documents.
Compare your own documents side by side first, as the switching guide shows, then switch.