What is FastPDF?
FastPDF is a production-ready API for rendering PDFs from HTML or live URLs. Send a single POST request with your API key and receive a base64-encoded PDF — optimized for backend workflows, receipts, invoices, reports, and automated document generation.
Next steps: open the Setup guide, then jump to Convert HTML to PDF or Convert URL to PDF.
Page Layout
Control the physical dimensions, orientation, and scale of the rendered page. Dimension values accept standard CSS units: in cm mm pt px. Defaults match US Letter (8.5 × 11 in) with 0.39 in margins.
paperSets the PDF page dimensions.
widthPage width. e.g. "8.5in", "21cm". Default: "8.5in".
heightPage height. e.g. "11in", "29.7cm". Default: "11in".
marginSets page margins. Each sub-field accepts the same CSS dimension units.
topTop margin. Default: "0.39in".
bottomBottom margin. Default: "0.39in".
leftLeft margin. Default: "0.39in".
rightRight margin. Default: "0.39in".
landscapeRender in landscape orientation. Width and height semantics are swapped. Default: false.
scaleZoom factor applied to the page content. Accepts 0.1–2.0. Default: 1.0.
single_pageCollapse all content onto a single, arbitrarily tall page. Ignores CSS page-break rules. Default: false.
prefer_css_page_sizeUse dimensions from CSS @page rules instead of the paper fields above. Default: false.
Background
By default, Chromium omits CSS backgrounds when printing to PDF — matching the browser's default print behavior. Override with these flags.
print_backgroundInclude CSS background colors, gradients, and images in the PDF. Essential for dark-mode or branded documents. Default: false.
omit_backgroundHide the default white page background, producing a transparent canvas. Default: false.
JavaScript & Timing
Control when Chromium captures the page. Critical when your HTML renders dynamically — charts, lazy-loaded images, client-side frameworks. All three conditions can be combined; Chromium waits until all are satisfied.
wait_delayFixed pause after page load before capturing. Accepts Go duration strings: "500ms", "2s", "1m". Use as a last resort — prefer the selector or expression options below.
wait_for_expressionA JavaScript expression evaluated in the page context. Chromium waits until it returns true. e.g. "window.chartReady === true".
wait_for_selectorA CSS selector. Chromium waits until the matching element exists in the DOM. e.g. "#chart canvas".
Network
Control how Chromium handles external resource loading — remote stylesheets, fonts, and images referenced in your HTML.
skip_network_idleWhen false, Chromium waits until there are no in-flight network requests before capturing. Ensures remote resources are fully loaded. Default: true.
fail_on_resource_load_errorReturn a 502 error if any page asset fails to load. Useful in CI pipelines to catch broken asset references. Default: false.
Structure & Metadata
Embed navigational structure and descriptive metadata into the PDF. Metadata follows the XMP/Dublin Core standard and is visible in PDF readers.
generate_outlineEmbed a document outline (bookmarks panel) derived from heading hierarchy h1–h6. Enables in-PDF navigation in Acrobat and similar readers. Default: false.
metadataKey/value pairs written into the PDF's document metadata. Standard keys: Author Title Subject Keywords Creator. All values must be strings.
Rotate
Rotate specific pages post-render. Applied after Chromium renders content — useful for landscape appendices in an otherwise portrait document.
rotate_angleClockwise rotation to apply. Must be one of "90", "180", or "270".
rotate_pagesPages to rotate. Accepts range expressions: "1", "2-4", "1,3,5". Omit to rotate all pages.
Render a repeating header and/or footer on every page. Both fields accept a complete HTML document — not a fragment. Chromium renders them in isolation; external stylesheets from the main document are not available.
Chromium exposes special classes inside header/footer HTML: pageNumber totalPages pageDate title url. Use as <span class="pageNumber"></span>.
headerA complete HTML document rendered in the top margin area of each page. Use inline styles — external stylesheets are unavailable.
footerA complete HTML document rendered in the bottom margin area of each page. Same constraints as header.