Skip to Content

API Reference

The PageFlow API has a single endpoint for converting HTML to PDF.

Endpoint

POST https://api.pageflow.dev/convert


Request Body

The request body must be a JSON object containing either a url or html key.

ParameterTypeRequiredDescription
urlstringYes (or html)The URL of the page to convert to a PDF.
htmlstringYes (or url)A string of raw HTML to convert to a PDF.
optionsobjectNoAn object to specify PDF generation options.

The options Object

You can customize the PDF output by passing an options object. The following properties are supported:

PropertyTypeDefaultDescription
formatstring'A4'Paper format. E.g., 'Letter', 'A3', 'A4', etc.
landscapebooleanfalseIf true, sets the orientation to landscape.
printBackgroundbooleanfalseIf true, prints the background colors and images.
marginobject{}Sets the page margins. E.g., { "top": "1in" }.
scalenumber1Scales the rendering of the web page. (0.1 to 2).

The margin object can contain top, bottom, left, and right properties with string values (e.g., '10mm', '1in', '80px').


Example Request with Options

Here’s an example of how to generate a landscape, letter-sized PDF with a 1-inch top margin and background printing enabled.

curl -X POST \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com", "options": { "format": "Letter", "landscape": true, "printBackground": true, "margin": { "top": "1in", "bottom": "1in" } } }' \ --output custom-invoice.pdf \ https://api.pageflow.dev/convert