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.
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.
| Task | SnapshotFlow parameters | Result |
|---|---|---|
| Customer report export | url, format=pdf, wait_for_selector=.report-ready | Waits for the generated report page and streams a PDF. |
| Invoice or receipt from private HTML | html, format=pdf, pdf_paper_format=a4 | Renders a backend template without publishing a URL. |
| Marketing or audit archive | url, media_type=print, pdf_print_background=true | Exports a stable document from a live page. |
| Landscape dashboard handoff | pdf_landscape=true, pdf_paper_format=a4 | Keeps wide tables and charts easier to read. |
| Document link for a workflow | response_type=url, format=pdf | Returns 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.
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.
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.
Create a URL for downstream systems
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.
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
- MDN CSS paged media guide, last modified May 26, 2026.
- W3C CSS Paged Media Module Level 3 for page size, margins, orientation, and generated-page context.
- Chrome DevTools Protocol Page.printToPDF for the browser PDF export primitive.
- Puppeteer PDFOptions for Chromium PDF option context.
- Playwright page.pdf documentation for current browser automation PDF behavior.
- European Commission VAT in the Digital Age page for current digital reporting and e-invoicing context.
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