Page properties (converters)
Passproperties to convert() to control the generated PDF:
Every field of
size and margins defaults independently, so you can set just one dimension or margin and let Gotenberg fill in the rest.
Examples:
nativePages asks Chromium to print only some pages. To pick pages after printing, with odd, even, last and exclusions, use a select stage.
Single page
WhensinglePage is true, Chromium fits the entire content on one long page, as tall as the content.
Print media
Chromium uses print media by default. The PDF can look different from the browser (e.g. backgrounds omitted). UseprintBackground: true to include the page background, or set emulatedMediaType: "screen" (in conversion options) to use screen media. You can target print in CSS with @media print; use preferCssPageSize: true so Chromium respects @page size and margins.
Background logic
Chromium always prints the backgrounds of elements, such as table fills and colored boxes.printBackground and omitBackground decide the page’s own background, the one set on html and body:
Rendering and wait
Chromium captures the current DOM. If the page uses JavaScript to render content (e.g. SPAs, charts), use wait options so conversion runs when content is ready. PreferwaitForExpression, waitForSelector or waitForWindowStatus over waitDelay: they are more reliable. Use waitDelay only as a fallback when you cannot change the page; it is less reliable if load time varies.
Conversion options (converters)
In addition toproperties, convert() accepts:
- Wait:
waitDelay(e.g."5s"),waitForSelector,waitForExpression,waitForWindowStatus— see Rendering and wait - Header/footer:
header,footer— path,Buffer, orReadStream(see below) - User agent:
userAgent— override theUser-Agentheader sent by Chromium - Media:
emulatedMediaType("screen"or"print"),emulatedMediaFeatures— CSS media features the page sees, such as{ "prefers-color-scheme": "dark" } - HTTP:
extraHttpHeaders,cookies,failOnHttpStatusCodes,failOnResourceHttpStatusCodes,ignoreResourceHttpStatusDomains,failOnResourceLoadingFailed,skipNetworkIdleEvent,skipNetworkAlmostIdleEvent(see below) - Behavior:
failOnConsoleExceptions,failOnConsoleMessageTypes— answer 409 when the page throws, or writes one of these console types ("log","debug","info","warning","error","assert") - Accessibility:
nativeBookmarks(bookmarks from the headings; impliesnativeTaggedPdf),nativeTaggedPdf(a tagged PDF screen readers follow) - Post-processing:
stages— merge, split, stamp, encrypt, sign, make PDF/A or PDF/UA, and more, in order (see below) - Inputs:
archives,downloadFrom— see Files and downloads - Async delivery:
webhook— see Webhooks - Output:
outputFilename,trace— custom output filename and/or request trace id (see Request tracing)
Post-processing with stages
Chromium prints the PDF; anything after that is a stage. Chromium no longer makes PDF/A, encrypts, watermarks or writes metadata on its own: add the matching stage.split into several parts, the answer is a ZIP.
Header and footer
Headers and footers are rendered in an isolated context: your main page’s CSS does not apply, JavaScript does not run, and external requests (images, fonts, stylesheets) are not allowed. Provide complete HTML documents and style them in a<style> tag; set a font size, or the text is about one point tall. Chromium injects dynamic values into elements with these class names: pageNumber, totalPages, date, title, url. Use base64-encoded images inline (e.g. <img src="data:image/png;base64,...">). Add -webkit-print-color-adjust: exact; in your header/footer CSS if you need background or text colors to print.
HTTP and networking
extraHttpHeaders— Object of header name → value; sent with every request (main page and resources). You can scope a header to certain URLs by appending;scope=<regex>to the value (the token is stripped before sending).cookies— Array of{ name, value, domain }(and optionalpath,secure,httpOnly,sameSite) for authentication or session state.failOnHttpStatusCodes— Array of status codes (or ranges via X99 notation, e.g.499= 400–499). If the main page returns a matching code, Gotenberg returns 409 Conflict. Default is[499, 599].failOnResourceHttpStatusCodes— Same for subresources (images, CSS, scripts). UseignoreResourceHttpStatusDomainsto exclude hostnames from this check (e.g. analytics).failOnResourceLoadingFailed— Iftrue, conversion fails with 409 when a resource fails to load on the network (refused connection, unresolved host, blocked request); by default the PDF is still generated with missing assets.skipNetworkIdleEvent— Iftrue, Chromium does not wait for the network to be idle before converting (defaulttrue).skipNetworkAlmostIdleEvent— Iftrue, Chromium does not wait for the network to be almost idle before converting (defaulttrue). Set tofalseto wait for pages that fetch content after they load.
Screenshot options (capture)
Passproperties to capture() for image output:
Other
capture() options mirror the conversion options where applicable (e.g. userAgent, waitDelay, waitForSelector, extraHttpHeaders, cookies, archives, downloadFrom, webhook, outputFilename, trace, optimizeForSpeed). Screenshots produce an image rather than a PDF, so PDF-only options — header/footer, nativeBookmarks, nativeTaggedPdf and stages — don’t apply here. See Reference — screenshots.