Web to PDF API
Generate high-quality PDFs from any web page with custom page sizes, headers, footers, and print styles.
The Agenty PDF API renders any URL through headless Chrome and returns a high-quality PDF. You control page size, orientation, margins, headers, footers, and whether to include background graphics or honour @media print CSS.
By default the API returns the PDF binary. Pass responseType: "url" to upload the file to our CDN and receive a hosted URL instead — convenient for emails, dashboards, and async pipelines.
Features
- A4, Letter, customStandard sizes plus any custom width/height.
- Headers & footersDynamic page numbers and total page count.
- Print CSS supportRespects @media print for clean layouts.
- Background graphicsToggle background colours and images.
- Orientation controlPortrait or landscape per request.
- Multi-pageAutomatic page breaks and pagination.
- Password protectionOptional PDF password encryption.
- URL or bufferReturn raw PDF or hosted CDN URL via responseType.
Use cases
- Generate invoices and receipts from HTML templates
- Convert dashboards into shareable PDF reports
- Archive web pages for legal and compliance records
- Build eBooks by stitching multiple articles together
- Email-friendly statements and confirmations
API examples
curl -X POST https://api.agenty.ai/v1/pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/report"
}' \
--output report.pdfcurl -X POST https://api.agenty.ai/v1/pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/invoice",
"pageSize": "A4",
"margin": {"top": "20mm", "bottom": "20mm"},
"header": "Invoice #12345",
"responseType": "url"
}'const res = await fetch('https://api.agenty.ai/v1/pdf', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://example.com/report',
responseType: 'url', // get a link instead of the buffer
}),
});
const { url } = await res.json();
console.log('PDF URL:', url);import requests
res = requests.post(
"https://api.agenty.ai/v1/pdf",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"url": "https://example.com/report"},
)
with open("report.pdf", "wb") as f:
f.write(res.content)How Agenty compares
| Feature | Agenty | DocRaptor | PDFShift | HTML2PDF |
|---|---|---|---|---|
| URL to PDF | Yes | Yes | Yes | Yes |
| Custom headers/footers | Yes | Yes | Yes | Limited |
| Page size control | Yes | Yes | Yes | Limited |
| Hosted URL response | Yes | Limited | Yes | No |
| Free tier | Yes | No | Yes | Yes |
Frequently asked questions
What is the Web to PDF API?
The Agenty PDF API converts any web page into a high-quality PDF. You can control page size, orientation, margins, headers, footers, and whether to include background graphics.
How do I get a URL instead of the PDF binary?
Pass responseType: "url" in your request body. The API uploads the generated PDF to our CDN and returns a hosted link in JSON — useful for emails, webhook-driven jobs, and async pipelines.
Can I add headers and footers?
Yes. Pass header and footer strings, with placeholders like {{pageNumber}} and {{totalPages}} for dynamic pagination.
Does it respect @media print CSS?
Yes. We apply @media print styles during rendering. You can also pass custom CSS via the customCss parameter to override styles before PDF generation.
Is there a free tier?
Yes. All accounts include free credits. Check our pricing page for details.