/forms/chromium/convert/htmlGotenberg 8Gotenberg 9Convert HTML to PDF
Prints index.html, with the files it names, to PDF, laid out as Chromium prints it. Off with --chromium-disable-routes.
printf '<!doctype html><html><body><h1>Hello</h1><p>Made by marqius-kern.</p></body></html>' > index.html
curl http://localhost:3000/forms/chromium/convert/html -F files=@index.html -o hello.pdfprintf '<!doctype html><html><body><h1>Hello</h1><p>Made by marqius-kern.</p></body></html>' > index.html
marqius-kern run /forms/chromium/convert/html -F files=@index.html -o hello.pdf# Python 3 with requests (pip install requests)
import requests
with open("index.html", "w") as f:
f.write("<!doctype html><html><body><h1>Hello</h1><p>Made by marqius-kern.</p></body></html>")
r = requests.post("http://localhost:3000/forms/chromium/convert/html", files=[
("files", ("index.html", open("index.html", "rb"))),
])
r.raise_for_status()
with open("hello.pdf", "wb") as f:
f.write(r.content)// Node 18 or later: save as sample.mjs, then run node sample.mjs
import { readFile, writeFile } from "node:fs/promises";
await writeFile("index.html", "<!doctype html><html><body><h1>Hello</h1><p>Made by marqius-kern.</p></body></html>");
{
const form = new FormData();
form.append("files", new Blob([await readFile("index.html")]), "index.html");
const res = await fetch("http://localhost:3000/forms/chromium/convert/html", { method: "POST", body: form });
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
await writeFile("hello.pdf", Buffer.from(await res.arrayBuffer()));
}printf '<!doctype html><html><body><h1>Hello</h1><p>Made by marqius-kern.</p></body></html>' > index.html
curl http://localhost:3000/forms/chromium/convert/html -F files=@index.html -F paperSize=A4 -F 'stages=[{"op":"set-metadata","title":"Hello"}]' -o hello-a4.pdfprintf '<!doctype html><html><body><h1>Hello</h1><p>Made by marqius-kern.</p></body></html>' > index.html
marqius-kern run /forms/chromium/convert/html -F files=@index.html -F paperSize=A4 -F 'stages=[{"op":"set-metadata","title":"Hello"}]' -o hello-a4.pdf# Python 3 with requests (pip install requests)
import requests
with open("index.html", "w") as f:
f.write("<!doctype html><html><body><h1>Hello</h1><p>Made by marqius-kern.</p></body></html>")
r = requests.post("http://localhost:3000/forms/chromium/convert/html", files=[
("files", ("index.html", open("index.html", "rb"))),
("paperSize", (None, "A4")),
("stages", (None, "[{\"op\":\"set-metadata\",\"title\":\"Hello\"}]")),
])
r.raise_for_status()
with open("hello-a4.pdf", "wb") as f:
f.write(r.content)// Node 18 or later: save as sample.mjs, then run node sample.mjs
import { readFile, writeFile } from "node:fs/promises";
await writeFile("index.html", "<!doctype html><html><body><h1>Hello</h1><p>Made by marqius-kern.</p></body></html>");
{
const form = new FormData();
form.append("files", new Blob([await readFile("index.html")]), "index.html");
form.append("paperSize", "A4");
form.append("stages", "[{\"op\":\"set-metadata\",\"title\":\"Hello\"}]");
const res = await fetch("http://localhost:3000/forms/chromium/convert/html", { method: "POST", body: form });
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
await writeFile("hello-a4.pdf", Buffer.from(await res.arrayBuffer()));
}Form fields 100
filesfilesrequiredGotenberg 8index.html and the files it names (stylesheets, pictures, fonts, scripts), each by its name alone. header.html and footer.html are printed in the top and bottom margins of every page (classes date, title, url, pageNumber and totalPages take those values); Marqius Kern's own header-first.html and footer-first.html stand in for them on the first page (an empty one: none there).
downloadFromJSONGotenberg 8Files to fetch first, as if they had been sent with the request: a list of objects with a
urland, optionally,extraHttpHeadersandembedded(true: carried inside the PDF as an attachment). Fetched as the server's--api-download-from-*rules allow.skipNetworkIdleEventbooleandefaulttrueGotenberg 8checked onlyPrints without waiting for the network to go idle. Marqius Kern checks the value (a wrong one is refused, in Gotenberg's words); it changes nothing in Marqius Kern's answer.
skipNetworkAlmostIdleEventbooleandefaulttrueGotenberg 8checked onlyPrints without waiting for the network to go almost idle. Marqius Kern checks the value (a wrong one is refused, in Gotenberg's words); it changes nothing in Marqius Kern's answer.
failOnHttpStatusCodesJSONdefault[499,599]Gotenberg 8Answers 409 when the page itself answers one of these statuses: 499 stands for 400 to 499, 599 for 500 to 599.
failOnResourceHttpStatusCodesJSONGotenberg 8Answers 409 when a file the page loads (a picture, a stylesheet, a script) answers one of these statuses; ranges as for failOnHttpStatusCodes.
ignoreResourceHttpStatusDomainsJSONGotenberg 8Domains, their subdomains included, that failOnResourceHttpStatusCodes leaves out: ["sentry-cdn.com"].
failOnResourceLoadingFailedbooleandefaultfalseGotenberg 8Answers 409 when a file the page loads cannot be fetched at all.
failOnConsoleExceptionsbooleandefaultfalseGotenberg 8Answers 409 when the page's script throws an exception.
failOnConsoleMessageTypesJSONGotenberg 8Answers 409 when the page writes one of these console types: log, debug, info, warning, error or assert.
waitDelaystringa duration: 500ms, 2s, 1m30sGotenberg 8Waits this long once the page has loaded, before printing: 500ms, 2s.
waitForExpressionstringGotenberg 8Waits until this JavaScript expression is true, such as
window.ready === true.waitForSelectorstringGotenberg 8Waits until an element matching this CSS selector is on the page, such as
#chart.ready.cookiesJSONGotenberg 8Cookies to set before the page loads: objects with a
name, avalueand adomain, and optionally apath,secure,httpOnlyandsameSite(Strict, Lax or None).userAgentstringGotenberg 8The User-Agent header the page's requests send.
extraHttpHeadersJSONGotenberg 8Headers the page's requests send: {"X-Token": "abc"}. A value ending in
;scope=<regex>is sent only to the addresses the regex matches.emulatedMediaTypeprint | screendefaultprintGotenberg 8The CSS media type the page is laid out for.
emulatedMediaFeaturesJSONGotenberg 8CSS media features the page sees: {"prefers-color-scheme": "dark"}.
omitBackgroundbooleandefaultfalseGotenberg 8Leaves out the white background, for a transparent page or picture; a PDF needs printBackground too.
landscapebooleandefaultfalseGotenberg 8Prints the page on its side.
printBackgroundbooleandefaultfalseGotenberg 8Prints the page's backgrounds; without it only what the page marks
print-color-adjust: exactkeeps them, as in Chromium.scalenumberdefault1.00.1 to 2Gotenberg 8Draws the content this many times as big, from 0.1 to 2.
singlePagebooleandefaultfalseGotenberg 8Prints the whole content on one page, as tall as the content.
paperWidthstringdefault8.5a length: 8.5, 210mm, 8.27inGotenberg 8The paper's width: inches, or a number with a unit (210mm, 21cm, 595pt, 794px).
paperHeightstringdefault11a length: 8.5, 210mm, 8.27inGotenberg 8The paper's height.
marginTopstringdefault0.39a length: 8.5, 210mm, 8.27inGotenberg 8The top margin; header.html prints in it.
marginBottomstringdefault0.39a length: 8.5, 210mm, 8.27inGotenberg 8The bottom margin; footer.html prints in it.
marginLeftstringdefault0.39a length: 8.5, 210mm, 8.27inGotenberg 8The left margin.
marginRightstringdefault0.39a length: 8.5, 210mm, 8.27inGotenberg 8The right margin.
preferCssPageSizebooleandefaultfalseGotenberg 8checked onlyGives the page's own CSS @page size priority over paperWidth and paperHeight. Marqius Kern checks the value (a wrong one is refused, in Gotenberg's words); it changes nothing in Marqius Kern's answer.
generateDocumentOutlinebooleandefaultfalseGotenberg 8Makes bookmarks from the page's headings.
generateTaggedPdfbooleandefaultfalseGotenberg 8Makes a tagged PDF, whose structure screen readers follow.
nativePageRangesstringGotenberg 8The pages to print, in Chromium's syntax: 1-5, 8, 11-13.
splitModeintervals | pagesGotenberg 8Splits the PDF:
intervalsinto parts of splitSpan pages,pagesinto the pages splitSpan names. Several parts are answered as a ZIP.splitSpanstringGotenberg 8The pages of each part: a number of pages for intervals, page ranges (1-3, 5) for pages.
splitUnifybooleandefaultfalseGotenberg 8With splitMode pages: the pages chosen in one PDF instead of one PDF each.
metadataJSONGotenberg 8The PDF's metadata to write: {"Author": "…", "Title": "…", "Keywords": ["…"]}.
flattenbooleandefaultfalseGotenberg 8Turns form fields and annotations into the page's own drawing.
userPasswordstringGotenberg 8The password that opens the PDF.
ownerPasswordstringGotenberg 8The password that lifts the PDF's restrictions.
allowPrintingbooleandefaulttrueGotenberg 8With a password: printing allowed.
allowModifyingbooleandefaulttrueGotenberg 8With a password: changes allowed.
allowCopyingbooleandefaulttrueGotenberg 8With a password: copying text and pictures allowed.
allowAnnotatingbooleandefaulttrueGotenberg 8With a password: comments allowed.
allowFillingFormsbooleandefaulttrueGotenberg 8With a password: filling in forms allowed.
allowAssemblingbooleandefaulttrueGotenberg 8With a password: inserting, rotating and deleting pages allowed.
stampfilesGotenberg 8A picture or a PDF drawn over the pages (stampSource image or pdf).
stampSourcetext | image | pdfGotenberg 8What the stamp is: text (stampExpression), or the picture or PDF sent as
stamp.stampExpressionstringGotenberg 8The stamp's text, or the name of its file.
stampPagesstringGotenberg 8The pages stamped: 1-3, 5; all when not given.
stampOptionsJSONGotenberg 8How the stamp is drawn: {"font": "Helvetica", "fontSize": 24, "color": "#ff0000", "opacity": 0.5, "rotation": 45, "position": "center"}.
watermarkfilesGotenberg 8A picture or a PDF drawn under the pages' content (watermarkSource image or pdf).
watermarkSourcetext | image | pdfGotenberg 8What the watermark is: text (watermarkExpression), or the picture or PDF sent as
watermark.watermarkExpressionstringGotenberg 8The watermark's text, or the name of its file.
watermarkPagesstringGotenberg 8The pages watermarked: 1-3, 5; all when not given.
watermarkOptionsJSONGotenberg 8How the watermark is drawn, as for stampOptions.
rotateAngle90 | 180 | 270Gotenberg 8Turns the pages by this angle, clockwise.
rotatePagesstringGotenberg 8With rotateAngle: the pages turned: 1-3, 5; all when not given.
optimizeImagesbooleandefaultfalseGotenberg 8Packs the pictures again as JPEG, for a smaller file.
imageQualityinteger1 to 100Gotenberg 8With optimizeImages: the JPEG quality, from 1 to 100.
kernOcrtrue | false | autodefaultfalseMarqius Kerntrue (or auto): the pages that need it (scans: little text and a large picture) are read and laid over with hidden text, so the PDF can be searched and copied; the pages look as they did. The summary is in the X-Marqius-Kern-Ocr header.
kernOcrEnginestringMarqius KernThe engine that reads: Marqius Kern's own (the server's --kern-ocr-engine unless sent: ppocr-v6-tiny; ppocr-v6-small reads more accurately), tesseract, a folder added with
marqius-kern ocr add, or an OCR server's name (--kern-ocr-server).kernOcrLanguagesstringMarqius KernThe languages or scripts on the pages, comma-separated (ara, heb, hi, korean...): the default engine is swapped for Marqius Kern's engine that reads them.
kernOcrPagesstringMarqius KernThe pages to read if they need it: 1-3,5, even, odd, !1; all unless sent.
kernOcrOptionalbooleandefaultfalseMarqius KernWhen OCR cannot run (no engine, a model not fetched yet), the file is answered as it is, with a note, instead of an error.
pdfaPDF/A-1b | PDF/A-2b | PDF/A-3bGotenberg 8Makes the PDF this PDF/A level, for archiving.
pdfuabooleandefaultfalseGotenberg 8Makes the PDF accessible (PDF/UA).
embedsfilesGotenberg 8Files carried inside the PDF as attachments.
embedsMetadataJSONGotenberg 8For each file carried inside, by its name: {"invoice.xml": {"mimeType": "text/xml", "relationship": "Data"}}.
facturxXmlfilesGotenberg 8A Factur-X or ZUGFeRD invoice's XML: the PDF is made an e-invoice carrying it (PDF/A-3b).
facturxVersionstringdefault1.0Gotenberg 8The Factur-X version written in the PDF's metadata.
facturxConformanceLevelMINIMUM | BASIC WL | BASIC | EN 16931 | EXTENDED | XRECHNUNGGotenberg 8The invoice XML's profile, when the XML does not say it.
facturxDocumentTypeINVOICE | ORDER | ORDER_RESPONSE | ORDER_CHANGEGotenberg 8What the XML is.
kernBookFeaturesbooleanMarqius KernPrints what Chromium does not know: running headers (string-set, position: running()), page numbers in contents and cross-references (target-counter), leaders, footnotes (the server's --kern-book-features unless sent).
kernFitHeaderFooterbooleanMarqius KernA header.html or footer.html taller than its margin moves the page's text away rather than covering it (the server's --kern-fit-header-footer unless sent).
kernContentsbooleandefaultfalseMarqius KernA contents page at the front: the headings, each a link, with their page numbers.
kernContentsDepthintegerdefault31 to 6Marqius KernWith kernContents: the heading levels listed, 1 to 6.
kernContentsTitlestringdefaultContentsMarqius KernWith kernContents: the contents page's title.
kernFirstPageNumberintegerdefault1Marqius KernThe number the first page is given; the rest count on from it.
kernFontReportbooleanMarqius KernSays in the X-Marqius-Kern-Fonts header which fonts each conversion used, their files, and what stood in for what (the server's --kern-font-report unless sent).
kernRequireFontsstringMarqius KernFamilies this request must have, comma-separated: a conversion that cannot have one is refused (409) instead of printed in another font.
kernSignbooleanMarqius KernSigns the PDFs with the server's key (--kern-sign-certificate); false leaves them unsigned on a server that signs every PDF (--kern-sign-all, which is the default unless sent).
kernSignCertificatestringMarqius KernThe name of a file sent with the request to sign with: a PKCS #12 store (.p12, .pfx), or a PEM certificate with its key, or with the key in kernSignKey. The file is taken out of the request's files: never converted, and gone from the disk at once.
kernSignKeystringMarqius KernWith a PEM certificate that holds no key: the name of the file sent with the key.
kernSignCertificatePasswordstringMarqius KernOpens the store or the key; never logged, never echoed.
kernSignReasonstringMarqius KernThe reason the signature gives (the server's --kern-sign-reason unless sent).
kernSignLocationstringMarqius KernWhere the signature says it was made (the server's --kern-sign-location unless sent).
kernSignContactInfostringMarqius KernHow to reach the signer (the server's --kern-sign-contact-info unless sent).
kernSignNamestringMarqius KernThe signer's name, as the signature gives it (the server's --kern-sign-name unless sent).
kernSignPadesbooleandefaulttrueMarqius KernSigns as PAdES; false: the classic adbe.pkcs7.detached (the server's --kern-sign-pades unless sent).
kernSignTimestampUrlstringan addressMarqius KernAn RFC 3161 time-stamp authority, http or https, that stamps the signature's time (PAdES B-T); the server's --kern-sign-timestamp-url unless sent.
kernSignFieldstringMarqius KernSigns the PDF's empty signature field of this name, where that field is drawn; or names the new field.
kernSignBoxstringMarqius KernShows the signature in this box: page:left,bottom,width,height in points, the page 1, 2... or last, such as 1:36,36,200,60.
kernTimestampUrlstringan addressMarqius KernA document timestamp from this RFC 3161 authority, http or https: after the signature when there is one, alone otherwise.
stagesJSONGotenberg 9Operations run on the PDFs in order, each with its options as /forms/pdf's routes take them: a JSON array such as [{"op":"set-metadata","title":"Report"},{"op":"encrypt","userPassword":"open"}].
paperSizestringGotenberg 9A paper by name, such as A4 or Letter, in place of paperWidth and paperHeight.
nativePagesstringGotenberg 9The pages to print, in Chromium's syntax (1-5, 8, 11-13): Gotenberg 9's name for nativePageRanges.
nativeBookmarksbooleandefaultfalseGotenberg 9Makes bookmarks from the page's headings: Gotenberg 9's name for generateDocumentOutline.
nativeTaggedPdfbooleandefaultfalseGotenberg 9Makes a tagged PDF: Gotenberg 9's name for generateTaggedPdf.
waitForWindowStatusstringGotenberg 9Waits until the page sets window.status to this value, before printing.
Answers 11
- 200 The PDF; several (a split, or several documents not merged) as a ZIP. application/pdf, application/zip
- 204 The request is accepted: its result is sent to Gotenberg-Webhook-Url, or its failure to Gotenberg-Webhook-Error-Url.
- 400 A form field or a header is missing or wrong, in Gotenberg's words.
Invalid form data: form field 'scale' is invalid (got 'foo', resulting to strconv.ParseFloat: parsing "foo": invalid syntax) - 401 The credentials are missing or wrong, with --api-enable-basic-auth on.
- 403 The address lists refuse an address the request makes the server fetch:
Forbidden; the log says why. - 409 A failOn… check failed (the page or a file it loads answered an error, the console said what the request refuses), or a font the request requires is missing.
- 413 The request is larger than --api-body-limit allows.
- 429 The queue for this kind of conversion is full; try again shortly.
- 500 Something else failed; the request's trace identifier finds it in the log.
- 503 The request took longer than --api-timeout, or the server is stopping.
- 404 The route is off on this server, or there is no such route: {"message":"Not Found"}.
Webhooks 3
- The result, sent to your address
{$request.header.Gotenberg-Webhook-Url}
Once made, the result is sent here with the method Gotenberg-Webhook-Method names (POST unless PUT or PATCH), its Content-Disposition naming the file, your trace identifier in its header, and the headers of Gotenberg-Webhook-Extra-Http-Headers. The request itself was answered 204 at once. - A failure, sent to your address
{$request.header.Gotenberg-Webhook-Error-Url}
When the request cannot be answered, the status it would have had and why, with Gotenberg-Webhook-Error-Method (POST unless PUT or PATCH).{ "message": "Invalid form data: form field 'scale' is invalid (got 'foo', resulting to strconv.ParseFloat: parsing \"foo\": invalid syntax)", "status": 400 } - Each outcome, sent to your address
{$request.header.Gotenberg-Webhook-Events-Url}
webhook.success once the result is sent, webhook.error once a failure is, each with your trace identifier.{ "correlationId": "4f6c8a3e-2b1d-4c7e-9a5f-1e2d3c4b5a69", "event": "webhook.success", "timestamp": "2026-11-30T16:49:15.315Z" }
Turned off with --chromium-disable-routes.