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.
Example with units:
Standard paper sizes
Common sizes (width × height) you can use inproperties.size:
Single page
WhensinglePage is true, Chromium fits the entire content on one long page and overrides paper height and native page ranges.
Print media
Chromium uses print media by default. The PDF can look different from the browser (e.g. backgrounds omitted). UseprintBackground: true to include background graphics, 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
The resulting background depends onprintBackground, omitBackground, and whether your document has a background:
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 or waitForSelector 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— see Rendering and wait - Header/footer:
header,footer— path,Buffer, orReadStream(see below) - User agent:
userAgent— override theUser-Agentheader sent by Chromium - HTTP:
extraHttpHeaders,cookies,failOnHttpStatusCodes,failOnResourceHttpStatusCodes,ignoreResourceHttpStatusDomains,failOnResourceLoadingFailed,skipNetworkIdleEvent,skipNetworkAlmostIdleEvent(see below) - Behavior:
failOnConsoleExceptions,failOnResourceLoadingFailed,skipNetworkIdleEvent,skipNetworkAlmostIdleEvent - Async callbacks:
webhook(webhookUrl,webhookErrorUrl, optional methods/headers/events URL — at least one ofwebhookUrl/webhookErrorUrlis required whenwebhookis set;webhookErrorUrlis deprecated in favor ofwebhookEventsUrl) - Output:
outputFilename,trace— custom output filename and/or request trace id (see Request tracing) - PDF accessibility:
pdfUA(PDF/UA accessibility),generateTaggedPdf(PDF/UA structure tags, independent ofpdfUA),generateDocumentOutline(bookmarks from heading tags) pdfFormat— deprecated: Chromium no longer supports it since Gotenberg 8.0.0; usepdfaon PDFEngines.convert instead- Metadata:
metadata - Encryption:
userPassword,ownerPassword— see Encryption - Permissions:
allowPrinting,allowCopying,allowModifying,allowAnnotating,allowFillingForms,allowAssembling— see PDF permissions - Attachments:
embeds,embedsMetadata— see Embedding files - Factur-X / ZUGFeRD:
facturx— turn the resulting PDF into an e-invoice, see Factur-X - PDF-engine overlays:
watermark,stamp(post-processing) - PDF-engine rotation:
rotate—{ angle: 90 | 180 | 270; pages?: string }(optional second pass after render; see Rotate PDFs) - Split:
split—{ mode: "pages" | "intervals", span, unify? }(see Split PDFs;flattenbelow is a separate top-level option, not part ofsplit) - Flatten:
flatten— flatten the resulting PDF’s form fields and annotations (defaultfalse); see Flatten PDFs
Watermark and stamp (PDF engines)
You can setwatermark and stamp on converter convert() options. These are applied after Chromium renders the PDF:
watermarkoverlays behind page content.stampoverlays on top of page content.
source to "image" or "pdf", set expression to the uploaded filename, and pass the file via file. Option keys in options are engine-specific; see Gotenberg watermark docs and stamp docs.
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) are not allowed. Provide complete HTML documents. 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.downloadFrom—DownloadFromEntryorDownloadFromEntry[]for remote file fetching; each entry supportsurl, optionalextraHttpHeaders, and routing withfield("embedded","watermark","stamp").webhook— Request-level webhook headers for async processing (webhookUrl,webhookErrorUrl, optional method overrides, extra callback headers, and events URL).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 400 when any resource fails to load (e.g. 404 image); 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 (<=2open connections for 500ms) before converting (defaulttrue). Set tofalseto wait for almost-idle pages with long-lived requests.
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, downloadFrom, webhook, outputFilename, trace, optimizeForSpeed). Screenshots produce an image rather than a PDF, so PDF-only options — header/footer, generateDocumentOutline, userPassword/ownerPassword, embeds/embedsMetadata, facturx, permissions, split, flatten — don’t apply here. See Reference — screenshots.