HTML to PDF
document SyncConvert HTML or raw text to downloadable PDF documents
Overview
Convert HTML markup, raw text, or web pages into high-quality PDF documents. Our API uses a headless browser engine to render HTML exactly as it would appear in a web browser, ensuring accurate styling, fonts, and layout. Perfect for generating invoices, reports, certificates, and any document that needs to be shared or printed.
Parameters
Request body parameters for this API
| Name | Type | Required | Description |
|---|---|---|---|
html | string | Optional | HTML content to convert (mutually exclusive with text/url) |
text | string | Optional | Plain text to convert (mutually exclusive with html/url) |
url | string | Optional | URL of web page to convert (mutually exclusive with html/text) |
options.format | string | Optional | Page format: A4, A3, A5, Letter, Legal, Tabloid (default: A4) |
options.landscape | boolean | Optional | Use landscape orientation (default: false) |
options.margin.top | string | Optional | Top margin (e.g., '20mm') |
options.margin.right | string | Optional | Right margin (e.g., '20mm') |
options.margin.bottom | string | Optional | Bottom margin (e.g., '20mm') |
options.margin.left | string | Optional | Left margin (e.g., '20mm') |
options.printBackground | boolean | Optional | Print background graphics (default: true) |
options.scale | number | Optional | Scale factor 0.1-2 (default: 1) |
Response
Response fields returned by this API
| Field | Type | Description |
|---|---|---|
Content-Type | header | application/pdf |
Content-Disposition | header | attachment; filename='document-{id}.pdf' |
X-Job-Id | header | Unique job identifier |
X-Credits-Charged | header | Number of credits charged |
body | binary | PDF file buffer |
Examples
Code examples coming soon
Detailed code examples in multiple languages will be added here.
Features
- HTML, text, or URL input
- Accurate CSS rendering
- Custom page formats (A4, Letter, etc.)
- Portrait or landscape orientation
- Custom margins and scaling
- Background printing support
- Header and footer templates
- Fast synchronous response
Use Cases
- Invoice and receipt generation
- Report and certificate creation
- Converting web pages to PDF
- Document archival
- Email attachment generation
- Printable ticket creation
Quick Links