printpipe.io
Docs: Conversion API

Conversion API

One endpoint turns HTML or a URL into a PDF or an image, rendered in a real, up-to-date browser. Send JSON or an HTML file, get the file back in the response body.

POSThttps://api.printpipe.io/v1/generate

For Postman, Insomnia or a generated client: the OpenAPI description.

Parameters

JSON body, Content-Type: application/json. Only html is required. Unknown parameters are rejected, so a typo never fails silently. null means “not set”.

Source

NameTypeDefaultDescription
htmlrequiredstring–The HTML to convert, or a public URL (http or https) to open. Up to 5 MB; for larger pages pass a URL. Not needed with templateId.
templateIdstring–Instead of html: the id of a template you saved in your dashboard (under Templates). It is filled in with data.
dataobject–The values for templateId, as JSON. {{name}} in the template prints a value (HTML-escaped), {{#items}}…{{/items}} repeats for each item of a list.
cssstring–Override CSS for this request, e.g. a customer’s brand colours: added after the styles of the HTML (or of the template, including its own override CSS), so it wins. Plain CSS, not filled with data. Works with html and templateId, not with a URL.

Output

NameTypeDefaultDescription
output"pdf" | "png" | "jpeg""pdf"What to produce: a PDF, or a screenshot of the page as PNG or JPEG. Screenshots cost credits like PDFs (1 per started MB).
filenamestring–File name for the result (sent in Content-Disposition). ".pdf", ".png" or ".jpg" is added when missing.

Page

NameTypeDefaultDescription
format"Letter" | "Legal" | "Tabloid" | "Ledger" | "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6""A4"Paper size. Ignored when width and height are set, and for screenshots.
landscapebooleanfalseLandscape orientation.
widthinteger (px)–Custom page width in CSS pixels (96 per inch). Use together with height. Screenshots: the browser window width (default 1280).
heightinteger (px)–Custom page height in CSS pixels. Use together with width. Screenshots: the browser window height (default 800).
singlePage
BasicPlusProEnterprise
booleanfalsePut the whole document on one page as tall as the content (up to 200 inches). Width comes from width or format; height is ignored.
marginTopinteger (px)0Top margin in CSS pixels.
marginRightinteger (px)0Right margin in CSS pixels.
marginBottominteger (px)0Bottom margin in CSS pixels.
marginLeftinteger (px)0Left margin in CSS pixels.

Rendering

NameTypeDefaultDescription
media"screen" | "print""screen"Which CSS media type to apply: screen styles (as in a browser window) or your @media print rules.
printBackgroundbooleantruePrint background colours and images.
scalenumber (0.1–2)1Zoom factor for the content. Screenshots: the pixel density, e.g. 2 for a sharp (retina) image twice the size.
waitFornumber (0–10 s; Free: 0–3 s)0Extra seconds to wait after the page loaded, for content added by JavaScript.
lazyLoadboolean–Scroll through the page first, so images and sections that load or fade in on scroll appear (stops after 12 s). Default: on for URLs, off for HTML; set false to skip it for a URL.
acceptCookiesboolean–Click "Accept all" on cookie banners first, so they don’t cover the page. Works with the common consent tools (OneTrust, Cookiebot, Didomi, Usercentrics and more) and banners in most European languages. Default: on for URLs, off for HTML; set false to capture the page as a first-time visitor sees it.

Header & footer

NameTypeDefaultDescription
headerTemplate
BasicPlusProEnterprise
string (HTML)–HTML printed at the top of every page. Elements with the classes pageNumber, totalPages, date, title and url are filled in. Needs a top margin to be visible.
footerTemplate
BasicPlusProEnterprise
string (HTML)–Like headerTemplate, at the bottom of every page. Needs a bottom margin.

Screenshot

NameTypeDefaultDescription
fullPageboolean–Screenshots only. Capture the whole page (default), or false for just the browser window. Pages are cut off at 16384 device pixels.
qualityinteger (1–100)–JPEG screenshots only. Image quality; higher is sharper and larger. Default 80.

Security

NameTypeDefaultDescription
userPassword
BasicPlusProEnterprise
string–Password needed to open the PDF. Setting it (or ownerPassword) encrypts the file with AES-256.
ownerPassword
BasicPlusProEnterprise
string–Password that lifts the permission restrictions. Random when you set only userPassword.
permissions
BasicPlusProEnterprise
array of "print", "modify", "copy", "edit", "fillform", "extract", "assemble", "printbest"["print"]What readers may do with an encrypted PDF without the owner password.

Async

NameTypeDefaultDescription
callBackUrlstring (URL)–Plus, Pro and Enterprise plans. Convert in the background: the API answers 202 at once and POSTs {"document": base64 file, "state": …, "contentType": "application/pdf"} to this public URL when done.
statestring–Any text (up to 1 KB) returned unchanged in the callback, e.g. your order id or a secret to verify the callback.

Responses

  • 200: the file itself (application/pdf, or image/png / image/jpeg for screenshots). Write the body to a file; don't parse it as JSON. Headers: X-Credits-Charged, X-Credits-Remaining and Content-Disposition (with your filename).
  • 202: accepted for background conversion (requests with callBackUrl).
  • 4xx / 5xx: JSON with an error code and a readable message, see Errors.

Sending an HTML file

Instead of JSON, you can send an HTML file as it is: as the request body with Content-Type: text/html and the options in the query string, or as a multipart form with the file in the file field and the options as other fields. Every option works as in JSON: write booleans as true or false, and lists like permissions comma-separated. The same 5 MB limit applies.

curl "https://api.printpipe.io/v1/generate?format=A4&marginTop=40&filename=report" \
  -H "X-API-Key: $API_KEY" \
  -H "Content-Type: text/html" \
  --data-binary @report.html \
  --output report.pdf
curl https://api.printpipe.io/v1/generate \
  -H "X-API-Key: $API_KEY" \
  -F "[email protected]" \
  -F "format=A4" \
  -F "permissions=print,copy" \
  --output report.pdf

Relative links in the file (<img src="logo.png">) can't load, because the page has no address of its own. Use absolute URLs, or embed images and fonts as data: URIs.

Screenshots

Set output to "png" or "jpeg" to get an image of the page instead of a PDF, on every plan. Images cost credits like PDFs: 1 per started MB.

{
  "html": "https://example.com",
  "output": "png",
  "width": 1440,
  "fullPage": true,
  "scale": 2
}
  • width and height set the browser window (default 1280 × 800). fullPage (default true) captures the whole page; false captures only the window.
  • scale is the pixel density: 2 gives a sharp image twice the size, like on a retina screen. quality (1–100) applies to JPEG.
  • PDF-only options (margins, landscape, headers and footers, passwords, singlePage) are refused with screenshots, so mistakes don't go unnoticed. Free plan images carry the same small watermark as PDFs.