PDF Generation
Convert HTML to pixel-perfect PDFs with native Tailwind CSS support.
/pdf
Generate a PDF from HTML with automatic Tailwind CSS support. Supports sync and async modes.
Request Headers
| Header | Required | Description |
|---|---|---|
Content-Type |
Required | Must be application/json |
X-API-Key |
Required | Your API authentication key |
X-No-Store |
Optional | Set to true to prevent HTML storage. Disables replay feature. |
Request Body Parameters
content
Required
string
The HTML content to render. Tailwind CSS classes are automatically supported.
<div class="p-8 bg-white"><h1 class="text-2xl font-bold">Invoice</h1></div>
fonts
Optional
array
Google Font families to load. Use the format from Google Fonts URL parameters.
["Poppins:wght@400;600;700","Inter:wght@400;500"]
tailwind_config
Optional
object
Custom Tailwind configuration to extend or override defaults.
{"theme":{"extend":{"colors":{"brand":"#4F46E5"}}}}
css_id
Optional
string
ID of a pre-uploaded CSS asset. When provided, the CSS is injected
my-brand-styles-v2
pdfOptions
Optional
object
PDF output options for customizing paper size, orientation, margins, and scaling.
format
a4
width
height
scale
1
landscape
false
printBackground
true
margin
viewport
Optional
object
Browser viewport dimensions for rendering. Controls the virtual browser window
width
1920
height
1080
deviceScaleFactor
1
waitFor
Optional
integer
Additional time to wait (in milliseconds) after page load before generating PDF.
Async Mode
Generate PDFs asynchronously and upload directly to your S3-compatible storage. Perfect for batch processing or when your client has short timeouts.
async
Optional
boolean
Enable async mode. When true, the API returns immediately with a job ID,
upload_url
Required if async
string
**Required when `async: true`**
webhook_url
Optional
string
**Optional, only used when `async: true`**
Async Response
{
"job_id": "01JFXYZ123456789ABCDEFGH",
"status": "pending",
"status_url": "/jobs/01JFXYZ123456789ABCDEFGH"
}
Poll the status_url or wait for the webhook. See Async Jobs for details.
Password Protection
Encrypt PDFs with AES-256 encryption. Requires dedicated workers.
password
Optional
object
Password protection settings for the PDF.
user string
Password required to open/view the PDF
owner string
Password that grants full access (bypasses all restrictions)
permissions object
Restrictions: print, copy, modify, annotate (all boolean)
Password Example
{
"content": "<div class=\"p-8\">Confidential Report</div>",
"password": {
"user": "viewonly123",
"owner": "admin456",
"permissions": {
"print": true,
"copy": false,
"modify": false,
"annotate": false
}
}
}
Paper Formats
Examples
Basic PDF
curl -X POST https://api.tailpdf.com/pdf \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"content": "<div class=\"p-8\"><h1 class=\"text-3xl font-bold text-gray-900\">Hello World</h1></div>"
}' \
--output output.pdf
With Google Fonts
curl -X POST https://api.tailpdf.com/pdf \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"content": "<div class=\"p-8 font-[Poppins]\"><h1 class=\"text-3xl font-bold\">Branded Document</h1></div>",
"fonts": [
"Poppins:wght@400;600;700"
]
}' \
--output output.pdf
With Custom Tailwind Config
curl -X POST https://api.tailpdf.com/pdf \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"content": "<div class=\"p-8 bg-brand text-white\"><h1 class=\"text-3xl font-bold\">Custom Colors</h1></div>",
"tailwind_config": {
"theme": {
"extend": {
"colors": {
"brand": "#4F46E5"
}
}
}
}
}' \
--output output.pdf
Custom Paper Size (Receipt)
curl -X POST https://api.tailpdf.com/pdf \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"content": "<div class=\"p-2 text-sm\"><h1 class=\"text-center font-bold\">RECEIPT</h1><hr class=\"my-2\"/><p>Item 1 - $10.00</p></div>",
"viewport": {
"width": 300
},
"pdfOptions": {
"width": "80mm",
"height": "200mm",
"margin": {
"top": "5mm",
"right": "5mm",
"bottom": "5mm",
"left": "5mm"
}
}
}' \
--output output.pdf
High-DPI Retina Output
curl -X POST https://api.tailpdf.com/pdf \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"content": "<div class=\"p-8\"><h1 class=\"text-3xl font-bold\">Sharp Text</h1></div>",
"viewport": {
"width": 1920,
"height": 1080,
"deviceScaleFactor": 2
}
}' \
--output output.pdf
Async with S3 Upload
curl -X POST https://api.tailpdf.com/pdf \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"content": "<div class=\"p-8\"><h1 class=\"text-2xl font-bold\">Invoice #1234</h1></div>",
"fonts": [
"Inter:wght@400;600"
],
"async": true,
"upload_url": "https://my-bucket.s3.amazonaws.com/pdfs/invoice-1234.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&...",
"webhook_url": "https://api.example.com/webhooks/pdf-ready"
}'
Health Check
/health
No auth required
{"status": "ok", "edge": true, "renderer": "cf-browser-rendering"}
{"status": "error", "error": "Chrome not connected"}
Next up
Async Jobs