Send a public webpage URL and receive that page back as a PDF file, base64 encoded. Each successful render costs one file credit from your plan.
Every request needs your API secret key in theAuthorization header as a Bearer token. Your email must be verified and your plan must include this feature with credit remaining.
Authorization: Bearer pigdf_your_api_secret_keyThe body is JSON with a required link field holding the URL, and an optional options object. The link must be a public http or https address; private, local, and unreachable hosts are rejected.
curl -X POST https://pigdf.com/api/render/link-to-pdf/ \
-H "Authorization: Bearer pigdf_your_api_secret_key" \
-H "Content-Type: application/json" \
-d '{
"link": "https://pigdf.com/",
"options": {
"landscape": true
}
}'Every option is optional. This example sends all of them at once, with each default noted. Leave options out entirely and you get an A4 portrait document with backgrounds printed at normal scale.
{
"link": "https://pigdf.com/", // required: a public http or https URL (up to 2048 characters)
"options": {
"page_size": { "width": 794, "height": 1123 }, // default: A4. Both 1-20000 px. Delete this for A4.
"landscape": false, // default: false (portrait). Safe to delete.
"margin": { "top": 40, "right": 40, "bottom": 40, "left": 40 }, // default: none. 0-20000 px per side. Include only the sides you want. Safe to delete.
"scale": 1, // default: 1. Range 0.1-2. Safe to delete.
"tagged": true, // default: false. Tagged, accessible PDF. Safe to delete.
"outline": true // default: false. Embeds an outline from the page headings. Safe to delete.
}
}
// JSON does not allow comments. Remove the comments above before sending.| Option | Type | Required | Default | Example | Notes |
|---|---|---|---|---|---|
| page_size | object | No | A4 | { "width": 794, "height": 1123 } | Custom page size as width and height in pixels, both between 1 and 20000. |
| tagged | boolean | No | false | true | Produces a tagged, accessible PDF that screen readers understand. |
| outline | boolean | No | false | true | Embeds a document outline built from the page headings. |
| landscape | boolean | No | false | true | Landscape orientation instead of portrait. |
| scale | number | No | 1 | 0.8 | Rendering scale between 0.1 and 2. |
| margin | object | No | none | { "top": 40, "left": 40 } | Page margins as top, right, bottom, and left in pixels, each between 0 and 20000. Include only the sides you need. |
Every response uses the same envelope: success, errors, and data. On success the PDF arrives base64 encoded in data.content; decode it and save it as a file.
{
"success": true,
"errors": [],
"data": {
"content": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9..."
}
}When something is wrong, success is false, data is empty, and errors holds one or more messages. The HTTP status tells you the category.
{
"success": false,
"errors": ["Your current plan does not include this feature."],
"data": {}
}| Status | When it happens | Message |
|---|---|---|
| 400 | The body is not valid JSON. | Invalid JSON. |
| 400 | The link field is missing or empty. | A non-empty "link" field is required. |
| 400 | The link is longer than 2048 characters. | The link exceeds the 2048 character limit. |
| 400 | The link is not a valid http or https URL. | Please provide a valid link that starts with http or https. |
| 400 | The link host is private, local, or unreachable. | The link points to a host that is private, local, or could not be resolved. |
| 401 | The API secret key is missing or wrong. | You are not authorized to use this API. |
| 403 | Your email is not verified. | Please verify your email address to use this API. |
| 403 | Your plan does not include this feature. | Your current plan does not include this feature. |
| 408 | The render took longer than 30 seconds. | Rendering took longer than 30 seconds. |
| 413 | The PDF produced is larger than 25 MB. | The generated PDF exceeds the 25 MB limit. |
| 429 | You have used all your credit for this feature. | You have used all your credit for this feature. |
| 502 | The webpage could not be rendered. | The linked webpage could not be rendered to a PDF. |
The link is limited to 2048 characters, and the PDF you receive is limited to 25 MB.
Only public http and https hosts are allowed; private, local, and unreachable hosts are rejected.
Rendering is limited to 30 seconds per request.
Failed requests never spend a credit. Only a successful render does.