Skip to main content
PDF Generation API

A PDF generation API that turns HTML or any URL into a PDF with one request

The Browserless PDF generation API renders your HTML or a live page in real Chrome and returns a paginated, text-searchable PDF. Headers, footers, page sizes, and wait conditions are request options, and there is no browser to install or scale.

175M+

Docker pulls

8 years

in production

99.9%

uptime

SOC 2

Type II

Trusted by engineering teams

Vivian HealthSamsaraMicrosoftWebflowIntelligent Audit

Security and compliance

See the Trust Center
SOC 2Type IIGDPRCompliantDPAAvailable

What is a PDF generation API?

A PDF generation API is an HTTP endpoint that takes HTML or a URL and returns a finished PDF, so your application never runs a browser or a PDF library itself. The Browserless /pdf endpoint loads your content in Chrome, waits for it to be ready, and prints it with the page size, margins, headers, and footers you specify. One POST request in, one application/pdf response out.

What teams generate with the PDF API

The /pdf endpoint sits behind billing systems, reporting jobs, and compliance pipelines.

  1. 01

    Invoices and receipts

    Render a billing template with the customer's data to a PDF the moment an order closes, with page numbers and your branding in the footer.

  2. 02

    Dashboard and report exports

    Print an authenticated dashboard or a scheduled report exactly as it renders, charts included, and email it or drop it into storage.

  3. 03

    Contracts and certificates

    Generate agreements, statements, and certificates from HTML so a design change is a template edit rather than a new PDF library.

  4. 04

    Email attachments

    Turn a transactional email's HTML into a PDF attachment in the same request pipeline that sends the message.

  5. 05

    Archiving web pages

    Capture a dated, text-searchable PDF of a page for compliance records, legal holds, or audit trails.

  6. 06

    Documentation and ebooks

    Compile long-form HTML into paginated PDFs with running headers and a document outline for navigation.

What the Browserless PDF API can render

The /pdf endpoint covers both halves of the job: HTML to PDF for templates you own, and URL to PDF for pages that already exist.

HTML to PDF
Send an html field with your markup and get a PDF back. Render invoices, reports, and certificates from a template without hosting the page anywhere first.
URL to PDF
Send a url and the API loads it in real Chrome, runs its JavaScript, and prints the rendered page. Single-page apps and dashboards come out the way they look on screen.
Headers and footers
Set displayHeaderFooter and pass HTML templates for the header and footer. The pageNumber, totalPages, date, title, and url classes fill in per page.
Page size and margins
Pick a format such as A4 or Letter, or set explicit width and height. Margins, landscape, scale, and pageRanges are all request options.
Wait for the right moment
Use waitForSelector, waitForFunction, waitForEvent, or waitForTimeout so charts, fonts, and late-loading data are on the page before it prints.
Inject styles and scripts
Use addStyleTag and addScriptTag to apply print CSS, load a font, hide navigation, or rewrite content before the PDF is generated.

How to generate a PDF with the Browserless API

Three steps, one POST request, and real Chrome doing the printing.

  1. 01

    Sign up for free

    Create a free Browserless account with no credit card required. The Free plan includes 1k units a month and 2 concurrent browsers, and your API token is in the dashboard as soon as you sign in.

  2. 02

    Send the request

    POST to the /pdf endpoint with a url or an html field, but not both, plus any options. Swap the host for production-lon or production-ams to render closer to your users.

  3. 03

    Handle the response

    The API responds with application/pdf binary. Save it to disk, stream it to the browser, or hand it to storage. The text stays selectable because Chrome prints the page rather than photographing it.

Each example is a complete request. Swap in your token and run it.

curl -X POST --fail-with-body \
  "https://production-sfo.browserless.io/pdf?token=YOUR_API_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://example.com/",
    "options": {
      "format": "A4",
      "printBackground": true
    }
  }' \
  --output "page.pdf"

The Node example renders raw HTML with a header and page-number footer. The Python example prints a URL after waiting for a selector. The clean-output example hides navigation, blocks ads and consent banners, and emits a tagged PDF.

The PDF options that matter

Everything under options maps to Chrome's print settings. These are the ones most requests end up setting.

Option

format, width, height
Named sizes such as A4, Letter, Legal, or Tabloid, or explicit dimensions in inches or any CSS unit. Defaults to 8.5in by 11in.
printBackground
Chrome drops background colours and images when printing. Set this to true for anything designed on screen.
displayHeaderFooter, headerTemplate, footerTemplate
HTML strings rendered on every page. Set an explicit font size; the default is too small to read.
margin
An object with top, right, bottom and left, each in inches or any CSS unit. Each side defaults to about 1cm.
landscape, scale, pageRanges
Orientation, a zoom factor for the rendered page, and a subset of pages such as 1-5, 8.
preferCSSPageSize
Let an @page rule in your stylesheet win over the format option.
tagged
Embed structure tags so screen readers and automated parsers can follow headings and reading order.
waitForSelector, waitForFunction, waitForEvent, waitForTimeout
Top-level request fields, alongside url or html, that hold the print until the page is ready.

The full list, including omitBackground, waitForFonts, and outline, is in the PDF API docs.

Hosted PDF API or do it yourself?

The honest version: each approach has a place. Here is where the lines fall.

Puppeteer page.pdf()

Best for
Full control from your own code, with the same Chrome print engine, for a handful of PDFs a day on infrastructure you already run.
Limitation
You install, patch, and scale Chrome yourself. Memory and zombie processes become your on-call problem.

wkhtmltopdf

Best for
Static, simple HTML where fidelity does not matter, from a single binary with no browser to manage.
Limitation
No longer maintained and built on an old WebKit engine, so CSS grid and flexbox, web fonts, and JavaScript-rendered content come out wrong or not at all.

Browserless /pdf

Best for
Production volume, dynamic pages, and any team that would rather not run browsers. Real, current Chrome over one HTTP call, with waiting, proxies, header and footer templates, and tagged output built in.
Limitation
A network round trip and a per-session unit instead of a library import.

Beyond PDFs: which Browserless API fits the job?

The PDF endpoint is one of several REST APIs in the Browserless platform, and none of them need a local browser or an installed automation library. Prefer the library route? The combined Screenshot, PDF and Screen Recording page covers Puppeteer and Playwright.

Capture a page as a PNG, JPEG, or WebP image instead of a PDFUse…Screenshot API
Get a page's rendered HTML, or run your own Puppeteer code over HTTPUse…REST APIs
Print a page that sits behind bot detection or a CAPTCHAUse…Web Unblocker
Keep page.pdf() in your own Puppeteer or Playwright scriptUse…Browsers as a Service

PDF generation API FAQs

PDF generation API FAQs

Ready to generate your first PDF?

Grab a token, paste the cURL call, and you have a PDF in a few seconds. The free plan includes 1k units a month, no credit card required.