How to Convert Any URL to PDF with an API (2026 Guide)
How to Convert Any URL to PDF with an API
Need to generate PDFs from web pages automatically? Whether you're building invoice generators, report exporters, or content archiving systems — a URL-to-PDF API saves you from dealing with headless browsers yourself.
The Problem with Self-Hosted PDF Generation
Running your own Puppeteer/Playwright setup for PDF generation means:
- Memory hungry — Chrome uses 200-500MB RAM per instance
- Font rendering issues — different servers render fonts differently
- Timeout headaches — complex pages with lots of JavaScript
- Scaling pain — each PDF blocks a browser instance
- Invoice generation — render an HTML invoice template, export as PDF
- Report exports — dashboard or analytics page → downloadable PDF
- Receipt generation — e-commerce order confirmations
- Content archiving — save web articles as PDFs for offline reading
- Legal documents — terms of service, contracts rendered from templates
- Free: 100 PDF exports/day
- Pro ($9/mo): 5,000/day
- Enterprise ($29/mo): 50,000/day
A PDF API handles all of this. Send a URL, get back a PDF.
Quick Start
cURL
`bash
curl -X POST https://api.16761.tech/pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","format":"A4"}' \
-o page.pdf
`
Python
`python
import requests
response = requests.post( "https://api.16761.tech/pdf", headers={"Authorization": "Bearer YOUR_API_KEY"}, json={ "url": "https://example.com", "format": "A4", "landscape": False, "printBackground": True } )
with open("output.pdf", "wb") as f:
f.write(response.content)
`
Node.js
`javascript
const response = await fetch("https://api.16761.tech/pdf", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
url: "https://example.com",
format: "Letter",
landscape: true
})
});
const buffer = await response.arrayBuffer();
require("fs").writeFileSync("output.pdf", Buffer.from(buffer));
`
Parameters
| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | url | string | required | URL to convert | | format | string | A4 | Paper size: A4, Letter, Legal, Tabloid | | landscape | boolean | false | Landscape orientation | | printBackground | boolean | true | Include background colors/images | | delay | integer | 0 | Wait ms after page load (max 10000) |