Complete API reference with request schema, parameter contracts, cURL examples, and sample responses.
Switch between APIs
Document APIs
Security APIs
Conversion APIs
OCR APIs
Utility APIs
File Management
Templates
Generate PDF from URL or HTML/CSS. Supports paper sizes, margins, landscape, fonts, wait strategies, and dynamic params.
Field-level request contract for this endpoint
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| url | string | Conditional | Target webpage URL. Required when html_content is not provided. | https://example.com |
| html_content | string | Conditional | Raw HTML markup. Required when url is not provided. | <h1>Hello</h1> |
| css_content | string | No | CSS styles used with html_content. | h1{font-size:32px;} |
| paper_size | string | No | A0–A6, Letter, Legal, Tabloid, Ledger. Default A4. | A4 |
| landscape | boolean | No | Landscape orientation. | false |
| print_background | boolean | No | Include CSS backgrounds. Default true. | true |
| displayHeaderFooter | boolean | No | Show header/footer. | false |
| preferCSSPageSize | boolean | No | Prefer CSS @page size over paper_size. | false |
| margin | string | object | No | Preset (none/small/medium/large) or object with top/right/bottom/left. | medium |
| viewPortWidth | integer | No | Viewport width. Default 1080. | 1080 |
| viewPortHeight | integer | No | Viewport height. Default 720. | 720 |
| font | string | No | Google Font names, pipe-separated. | Inter|Roboto |
| wait_until | string | No | load, domcontentloaded, networkidle, commit. | load |
| wait_till | integer | No | Extra delay in seconds after page load. | 2 |
| cookie_accept_text | string | No | Cookie consent button text to click (URL mode). | Accept ALL |
| dynamic_params | object | No | Key-value pairs for {{placeholder}} substitution. | {"name":"Rishabh"} |
| page_size | integer | No | Max pages to return (capped by plan). | 10 |
| output_format | string | No | url (default), file, base64, binary, pdf. | url |
| output_filename | string | No | Custom output filename. | report.pdf |
{
"html_content": "<h1>Invoice #1234</h1>",
"css_content": "h1 { font-size: 28px; }",
"paper_size": "A4",
"margin": "medium",
"print_background": true,
"output_format": "url"
}{
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "Target webpage URL. Required when html_content is not provided.",
"example": "https://example.com"
},
"html_content": {
"type": "string",
"description": "Raw HTML markup. Required when url is not provided.",
"example": "<h1>Hello</h1>"
},
"css_content": {
"type": "string",
"description": "CSS styles used with html_content.",
"example": "h1{font-size:32px;}"
},
"paper_size": {
"type": "string",
"description": "A0–A6, Letter, Legal, Tabloid, Ledger. Default A4.",
"example": "A4"
},
"landscape": {
"type": "boolean",
"description": "Landscape orientation.",
"example": "false"
},
"print_background": {
"type": "boolean",
"description": "Include CSS backgrounds. Default true.",
"example": "true"
},
"displayHeaderFooter": {
"type": "boolean",
"description": "Show header/footer.",
"example": "false"
},
"preferCSSPageSize": {
"type": "boolean",
"description": "Prefer CSS @page size over paper_size.",
"example": "false"
},
"margin": {
"type": "string",
"description": "Preset (none/small/medium/large) or object with top/right/bottom/left.",
"example": "medium"
},
"viewPortWidth": {
"type": "string",
"description": "Viewport width. Default 1080.",
"example": "1080"
},
"viewPortHeight": {
"type": "string",
"description": "Viewport height. Default 720.",
"example": "720"
},
"font": {
"type": "string",
"description": "Google Font names, pipe-separated.",
"example": "Inter|Roboto"
},
"wait_until": {
"type": "string",
"description": "load, domcontentloaded, networkidle, commit.",
"example": "load"
},
"wait_till": {
"type": "string",
"description": "Extra delay in seconds after page load.",
"example": "2"
},
"cookie_accept_text": {
"type": "string",
"description": "Cookie consent button text to click (URL mode).",
"example": "Accept ALL"
},
"dynamic_params": {
"type": "string",
"description": "Key-value pairs for {{placeholder}} substitution.",
"example": "{\"name\":\"Rishabh\"}"
},
"page_size": {
"type": "string",
"description": "Max pages to return (capped by plan).",
"example": "10"
},
"output_format": {
"type": "string",
"description": "url (default), file, base64, binary, pdf.",
"example": "url"
},
"output_filename": {
"type": "string",
"description": "Custom output filename.",
"example": "report.pdf"
}
},
"required": []
}{
"success": true,
"pdf_url": "https://cdn.pdfapihub.com/pdf/a1b2c3d4.pdf",
"file_size_bytes": 84321,
"file_deletion_date": "2026-05-04",
"source_type": "html"
}{
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"data": {
"type": "object",
"description": "Endpoint-specific response payload."
}
}
}curl -X POST https://pdfapihub.com/api/v1/generatePdf \
-H "CLIENT-API-KEY: your-api-key" \
-H "Content-Type: application/json" \
-d '{ "html_content": "<h1>Invoice #1234</h1>", "css_content": "h1 { font-size: 28px; }", "paper_size": "A4", "margin": "medium", "print_background": true, "output_format": "url" }'Common and endpoint-specific API error responses
Headers: CLIENT-API-KEY: <your-api-key> Content-Type: application/json Success HTTP status: 200 Success
| Code | Type | Reason |
|---|---|---|
| 400 | Invalid Request | Malformed JSON, invalid body shape, or missing required fields. |
| 401 | Unauthorized | Missing or invalid CLIENT-API-KEY. |
| 429 | Rate Limited | Request quota exceeded for current API key. |
| 500 | Internal Error | Unexpected processing failure. |
| 422 | Render Validation Failed | Invalid URL, unsupported HTML payload, or rendering options conflict. |
Generate endpoint-level OpenAPI JSON for SDK/client generation
{
"openapi": "3.0.3",
"info": {
"title": "PDF API Hub - Generate PDF",
"version": "1.0.0"
},
"paths": {
"/generatePdf": {
"post": {
"summary": "Generate PDF from URL or HTML/CSS. Supports paper sizes, margins, landscape, fonts, wait strategies, and dynamic params.",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "Target webpage URL. Required when html_content is not provided.",
"example": "https://example.com"
},
"html_content": {
"type": "string",
"description": "Raw HTML markup. Required when url is not provided.",
"example": "<h1>Hello</h1>"
},
"css_content": {
"type": "string",
"description": "CSS styles used with html_content.",
"example": "h1{font-size:32px;}"
},
"paper_size": {
"type": "string",
"description": "A0–A6, Letter, Legal, Tabloid, Ledger. Default A4.",
"example": "A4"
},
"landscape": {
"type": "boolean",
"description": "Landscape orientation.",
"example": "false"
},
"print_background": {
"type": "boolean",
"description": "Include CSS backgrounds. Default true.",
"example": "true"
},
"displayHeaderFooter": {
"type": "boolean",
"description": "Show header/footer.",
"example": "false"
},
"preferCSSPageSize": {
"type": "boolean",
"description": "Prefer CSS @page size over paper_size.",
"example": "false"
},
"margin": {
"type": "string",
"description": "Preset (none/small/medium/large) or object with top/right/bottom/left.",
"example": "medium"
},
"viewPortWidth": {
"type": "string",
"description": "Viewport width. Default 1080.",
"example": "1080"
},
"viewPortHeight": {
"type": "string",
"description": "Viewport height. Default 720.",
"example": "720"
},
"font": {
"type": "string",
"description": "Google Font names, pipe-separated.",
"example": "Inter|Roboto"
},
"wait_until": {
"type": "string",
"description": "load, domcontentloaded, networkidle, commit.",
"example": "load"
},
"wait_till": {
"type": "string",
"description": "Extra delay in seconds after page load.",
"example": "2"
},
"cookie_accept_text": {
"type": "string",
"description": "Cookie consent button text to click (URL mode).",
"example": "Accept ALL"
},
"dynamic_params": {
"type": "string",
"description": "Key-value pairs for {{placeholder}} substitution.",
"example": "{\"name\":\"Rishabh\"}"
},
"page_size": {
"type": "string",
"description": "Max pages to return (capped by plan).",
"example": "10"
},
"output_format": {
"type": "string",
"description": "url (default), file, base64, binary, pdf.",
"example": "url"
},
"output_filename": {
"type": "string",
"description": "Custom output filename.",
"example": "report.pdf"
}
},
"required": []
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"data": {
"type": "object",
"description": "Endpoint-specific response payload."
}
}
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"ApiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "CLIENT-API-KEY"
}
}
}
}