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.
Parameter | Type | Required | Description |
---|---|---|---|
url | string | Yes (or html ) | The URL of the page to convert to a PDF. |
html | string | Yes (or url ) | A string of raw HTML to convert to a PDF. |
options | object | No | An 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:
Property | Type | Default | Description |
---|---|---|---|
format | string | 'A4' | Paper format. E.g., 'Letter' , 'A3' , 'A4' , etc. |
landscape | boolean | false | If true , sets the orientation to landscape. |
printBackground | boolean | false | If true , prints the background colors and images. |
margin | object | {} | Sets the page margins. E.g., { "top": "1in" } . |
scale | number | 1 | Scales 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
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