Link to PDF.Any page, one call.

Back

Link to PDF

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.

Authentication

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_key

Endpoint

POSThttps://pigdf.com/api/render/link-to-pdf/

Request

The 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
    }
  }'

All options, annotated

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.

Options

OptionTypeRequiredDefaultExampleNotes
page_sizeobjectNoA4{ "width": 794, "height": 1123 }Custom page size as width and height in pixels, both between 1 and 20000.
taggedbooleanNofalsetrueProduces a tagged, accessible PDF that screen readers understand.
outlinebooleanNofalsetrueEmbeds a document outline built from the page headings.
landscapebooleanNofalsetrueLandscape orientation instead of portrait.
scalenumberNo10.8Rendering scale between 0.1 and 2.
marginobjectNonone{ "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.

Response

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..."
  }
}

Errors

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": {}
}
StatusWhen it happensMessage
400The body is not valid JSON.Invalid JSON.
400The link field is missing or empty.A non-empty "link" field is required.
400The link is longer than 2048 characters.The link exceeds the 2048 character limit.
400The link is not a valid http or https URL.Please provide a valid link that starts with http or https.
400The link host is private, local, or unreachable.The link points to a host that is private, local, or could not be resolved.
401The API secret key is missing or wrong.You are not authorized to use this API.
403Your email is not verified.Please verify your email address to use this API.
403Your plan does not include this feature.Your current plan does not include this feature.
408The render took longer than 30 seconds.Rendering took longer than 30 seconds.
413The PDF produced is larger than 25 MB.The generated PDF exceeds the 25 MB limit.
429You have used all your credit for this feature.You have used all your credit for this feature.
502The webpage could not be rendered.The linked webpage could not be rendered to a PDF.

Limits

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.