Changelog

Single-page PDFs

The new singlePage parameter puts the whole document on one page, as tall as its content, with no page breaks.

NewAPI

Set singlePage to true to get the whole document on one page, with no page breaks. The page is as tall as the content, so nothing is split between pages and no blank space is left at the end.

curl --fail --show-error --output page.pdf --request POST \
  --url https://api.html2pdf.app/v1/generate \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <your-api-key>' \
  --data '{ "html": "https://example.com", "singlePage": true, "width": 1280 }'

It suits receipts and order confirmations whose length varies, long web pages kept as one document, and reports or dashboards that are read on screen rather than printed.

How the page is sized

  • Width — width in pixels, or the width of format (its long side with landscape). height is ignored.
  • Height — the height of the content, plus marginTop and marginBottom.
  • Wide content — content up to 1.5 times wider than the page is scaled down to fit.
  • Page breaks — break rules such as break-after: page are ignored.
  • Headers and footers — headerTemplate and footerTemplate appear once, at the top and the bottom of the page.

Tips

  • For a URL whose images load on scroll, also set lazyLoad, so that they are loaded before the page is measured.
  • Elements fixed to the window, such as a sticky header or a cookie banner, appear once: at the top of the page, or at the bottom if they stay at the bottom of the window.
  • A very long page opens in browsers and most PDF viewers, but Adobe Acrobat cannot open a page taller than 200 inches (19,200 pixels).

See Single-page PDFs and Parameters in the documentation.