Keyword: webpage to PDF API ยท Updated August 3, 2026

Webpage to PDF API: Render Dynamic Pages as PDFs

A PDF export is often the last mile of a web workflow: a receipt after checkout, a customer report, a quote, a weekly audit, or an archive of a JavaScript-rendered page. The hard part is not saving bytes as .pdf. It is loading the same browser state your user sees, waiting for the page to finish, applying print CSS, preserving backgrounds when the design needs them, and returning a file your app can store or send.

Why this is timely

Browser-rendered documents are still moving. MDN's CSS paged media guide was updated on May 26, 2026 and describes the print-oriented CSS controls developers use for page size, page breaks, margins, and generated pages. The Chrome DevTools Protocol still exposes Page.printToPDF as the browser primitive behind many Chromium PDF workflows, including orientation and background options. Playwright and Puppeteer both document PDF generation from a rendered page, which keeps the developer mental model close to screenshots: navigate, wait, then export.

Business pressure is also current. The European Commission's VAT in the Digital Age page lists July 2026 implementation updates and a roadmap for digital reporting based on e-invoicing. That does not mean every team needs a specialized tax-compliance PDF API, but it does make automated, reproducible document generation a concrete engineering problem for SaaS billing, reporting, finance, and archive workflows.

SnapshotFlow fit: the verified backend supports format=pdf, pdf_print_background, pdf_landscape, pdf_paper_format, media_type=print, url or base64 html input, waits, injected styles, cookies, headers, and binary, URL, JSON, or base64 response modes.

When a webpage to PDF API is the right tool

Use PDF output when the artifact needs to be shared, attached, archived, printed, or reviewed outside the live application. Use an image screenshot when the goal is visual evidence, previews, thumbnails, or AI vision input.

TaskSnapshotFlow parametersResult
Customer report exporturl, format=pdf, wait_for_selector=.report-readyWaits for the generated report page and streams a PDF.
Invoice or receipt from private HTMLhtml, format=pdf, pdf_paper_format=a4Renders a backend template without publishing a URL.
Marketing or audit archiveurl, media_type=print, pdf_print_background=trueExports a stable document from a live page.
Landscape dashboard handoffpdf_landscape=true, pdf_paper_format=a4Keeps wide tables and charts easier to read.
Document link for a workflowresponse_type=url, format=pdfReturns a hosted URL instead of raw bytes.

For page-image evidence instead of document export, start with the full-page screenshot API guide. For generated PNG/WebP assets from HTML, see the HTML to Image API guide. For async long-running exports, pair this workflow with the async screenshot API with webhooks.

1. Convert a live URL to PDF with cURL

This request renders a dashboard report route, waits until the app marks the report ready, emulates print media, includes background graphics, and writes the PDF to disk.

curl --get "https://api.snapshotflow.com/screenshot" \ -H "X-Api-Key: $SNAPSHOTFLOW_API_KEY" \ --data-urlencode "url=https://example.com/reports/weekly" \ --data-urlencode "format=pdf" \ --data-urlencode "media_type=print" \ --data-urlencode "pdf_paper_format=a4" \ --data-urlencode "pdf_print_background=true" \ --data-urlencode "wait_until=networkidle2" \ --data-urlencode "wait_for_selector=.report-ready" \ --data-urlencode "block_cookie_banners=true" \ --output weekly-report.pdf

Expected behavior: SnapshotFlow validates the URL, renders it in Chromium, waits for .report-ready, calls the PDF export path, and returns application/pdf. If the selector never appears, the API returns SELECTOR_NOT_FOUND with HTTP 422 instead of producing a stale document.

Return a hosted PDF URL

Use response_type=url when another system needs a link rather than an attachment. The backend returns a plain-text storage URL.

curl --get "https://api.snapshotflow.com/screenshot" \ -H "X-Api-Key: $SNAPSHOTFLOW_API_KEY" \ --data-urlencode "url=https://example.com/invoices/1042" \ --data-urlencode "format=pdf" \ --data-urlencode "pdf_paper_format=letter" \ --data-urlencode "pdf_print_background=true" \ --data-urlencode "response_type=url"

2. Generate a PDF with the Node SDK

The official Node SDK is a thin HTTP wrapper. PDF output uses the same take() method as images; the content type changes to application/pdf.

import { SnapshotFlow } from "snapshotflow"; const client = new SnapshotFlow({ apiKey: process.env.SNAPSHOTFLOW_API_KEY, }); const pdf = await client.take({ url: "https://example.com/reports/weekly", format: "pdf", mediaType: "print", pdfPaperFormat: "a4", pdfPrintBackground: true, waitUntil: "networkidle2", waitForSelector: ".report-ready", blockCookieBanners: true, }); await pdf.save("weekly-report.pdf");

Create a URL for downstream systems

const pdfUrl = await client.takeUrl({ url: "https://example.com/invoices/1042", format: "pdf", pdfPaperFormat: "letter", pdfPrintBackground: true, }); console.log(pdfUrl);

3. Render private HTML to PDF

If your app already has the data for a receipt, quote, certificate, or invoice, sending raw HTML is often simpler than deploying a temporary URL. The SDK base64-encodes html before sending it to the API.

const invoicePdf = await client.take({ html: ` <!doctype html> <html> <head> <style> @media print { body { margin: 0; font-family: Arial, sans-serif; color: #111827; } .page { padding: 32px; } .line-items { width: 100%; border-collapse: collapse; } .line-items th, .line-items td { border-bottom: 1px solid #e5e7eb; padding: 10px; } .avoid-break { break-inside: avoid; } } </style> </head> <body> <main class="page"> <h1>Invoice #1042</h1> <p>Customer: Acme Operations</p> <section class="avoid-break"> <table class="line-items"> <tr><th>Item</th><th>Total</th></tr> <tr><td>Pro plan</td><td>$49.00</td></tr> </table> </section> </main> </body> </html> `, format: "pdf", mediaType: "print", pdfPaperFormat: "a4", pdfPrintBackground: true, }); await invoicePdf.save("invoice-1042.pdf");
Compliance note: SnapshotFlow can generate a visual PDF artifact. It does not add country-specific structured e-invoice payloads such as Factur-X, ZUGFeRD, or tax authority schemas. If your workflow has legal invoice requirements, validate the final artifact with the relevant compliance tooling.

Operational details and edge cases

Use print CSS deliberately

PDF is paged media, so test @media print, @page, and page-break rules. MDN and the W3C CSS Paged Media draft are useful references, but browser support is not identical to a dedicated publishing engine. Keep important blocks together with break-inside: avoid, hide navigation, and avoid relying on hover-only UI.

Know the current SnapshotFlow PDF controls

The verified public API exposes pdf_print_background, pdf_landscape, and pdf_paper_format. It does not currently expose custom PDF margins, header/footer templates, page ranges, scale, tagged PDF, document outline, or preferCSSPageSize. If those controls matter, keep the first draft scoped to what the API already supports or ask for a backend feature before publishing claims.

Wait for generated content

For reports and invoices assembled by client-side JavaScript, prefer a stable readiness marker such as .report-ready or [data-export-ready="true"]. Add a short delay only for assets that do not expose a clean DOM signal, such as custom fonts or late chart animations.

Handle authenticated pages carefully

SnapshotFlow supports request headers and cookies for pages your server is authorized to capture. Do not put long-lived API keys, session cookies, or bearer tokens into client-side URLs. For private dashboards, call SnapshotFlow from your backend and send credentials through the X-Api-Key header plus server-side headers or cookies options. The authenticated pages FAQ covers that boundary in more detail.

FAQ

Can SnapshotFlow convert a JavaScript page to PDF?

Yes. Pass the page URL, set format=pdf, and use wait_until plus wait_for_selector so the export happens after the JavaScript-rendered state is ready.

Can I generate a PDF from HTML without hosting the page?

Yes. Use the SDK html option, or send base64 HTML to the API's html parameter, then set format=pdf.

Can I get a base64 PDF response?

Yes. Set response_type=base64. The JSON response includes a data URL using the application/pdf MIME type.

Is this the same as an invoice compliance API?

No. SnapshotFlow renders browser-based PDF files. If your jurisdiction requires structured e-invoice formats, signatures, archiving rules, or validation against a tax schema, use dedicated compliance tooling around the generated document.

Sources

Build the export path once

SnapshotFlow lets your backend request screenshots, PDFs, diffs, text extraction, and async jobs from the same API surface. Start with the API reference or copy a recipe from the examples page, then keep the generated PDF draft under review before wiring it into customer-facing workflows.

View API docs