API Reference·v1.0

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.

bolt~50ms avg
verified99.9% uptime
data_objectREST + JSON
cloudHosted API

Next steps: open the Setup guide, then jump to Convert HTML to PDF or Convert URL to PDF.

article

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.

paper
objectconfig

Sets the PDF page dimensions.

width
string

Page width. e.g. "8.5in", "21cm". Default: "8.5in".

height
string

Page height. e.g. "11in", "29.7cm". Default: "11in".

margin
objectconfig

Sets page margins. Each sub-field accepts the same CSS dimension units.

top
string

Top margin. Default: "0.39in".

bottom
string

Bottom margin. Default: "0.39in".

left
string

Left margin. Default: "0.39in".

right
string

Right margin. Default: "0.39in".

landscape
booleanconfig

Render in landscape orientation. Width and height semantics are swapped. Default: false.

scale
numberconfig

Zoom factor applied to the page content. Accepts 0.1–2.0. Default: 1.0.

single_page
booleanconfig

Collapse all content onto a single, arbitrarily tall page. Ignores CSS page-break rules. Default: false.

prefer_css_page_size
booleanconfig

Use dimensions from CSS @page rules instead of the paper fields above. Default: false.

format_paint

Background

By default, Chromium omits CSS backgrounds when printing to PDF — matching the browser's default print behavior. Override with these flags.

print_background
booleanconfig

Include CSS background colors, gradients, and images in the PDF. Essential for dark-mode or branded documents. Default: false.

omit_background
booleanconfig

Hide the default white page background, producing a transparent canvas. Default: false.

timer

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_delay
stringconfig

Fixed 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_expression
stringconfig

A JavaScript expression evaluated in the page context. Chromium waits until it returns true. e.g. "window.chartReady === true".

wait_for_selector
stringconfig

A CSS selector. Chromium waits until the matching element exists in the DOM. e.g. "#chart canvas".

wifi

Network

Control how Chromium handles external resource loading — remote stylesheets, fonts, and images referenced in your HTML.

skip_network_idle
booleanconfig

When 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_error
booleanconfig

Return a 502 error if any page asset fails to load. Useful in CI pipelines to catch broken asset references. Default: false.

layers

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_outline
booleanconfig

Embed a document outline (bookmarks panel) derived from heading hierarchy h1–h6. Enables in-PDF navigation in Acrobat and similar readers. Default: false.

metadata
objectconfig

Key/value pairs written into the PDF's document metadata. Standard keys: Author Title Subject Keywords Creator. All values must be strings.

rotate_right

Rotate

Rotate specific pages post-render. Applied after Chromium renders content — useful for landscape appendices in an otherwise portrait document.

rotate_angle
stringconfig

Clockwise rotation to apply. Must be one of "90", "180", or "270".

rotate_pages
stringconfig

Pages 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.

info

Chromium exposes special classes inside header/footer HTML: pageNumber totalPages pageDate title url. Use as <span class="pageNumber"></span>.

header
stringbody

A complete HTML document rendered in the top margin area of each page. Use inline styles — external stylesheets are unavailable.

footer
stringbody

A complete HTML document rendered in the bottom margin area of each page. Same constraints as header.

HTML endpoint examples

POST/v1/convert/html
curl -X POST https://api.fastpdf.dev/v1/convert/html \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "html": "<h1>Hello, World!</h1>", "config": { "paper": { "width": "8.5in", "height": "11in" }, "margin": { "top": "1in", "bottom": "1in" }, "print_background": true }}' \ --output document.pdf
{ "content": "JVBERi0xLjQKJeLjz9MKMyAwIG9iago..."}