Simple API to convert HTML pages or raw HTML content to PDF documents.
Convert a web page URL to PDF:
curl --location 'https://pdf.kreating.dev' \
--header 'Content-Type: application/json' \
--data '{
"name": "event-ticket",
"url": "https://example.com/tickets/concert-2024"
}' \
--output event-ticket.pdfConvert raw HTML content to PDF:
curl --location 'https://pdf.kreating.dev/html' \
--header 'Content-Type: application/json' \
--data '{
"name": "invoice",
"html": "<!DOCTYPE html><html><head><style>body { font-family: Arial; padding: 40px; }</style></head><body><h1>Invoice #12345</h1><p>Amount: $99.00</p></body></html>"
}' \
--output invoice.pdfcurl https://pdf.kreating.dev/health| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Name for the generated PDF file (max 256 chars) |
url |
string | Yes | URL of the HTML page to convert (http/https only) |
options |
object | No | PDF generation options (see below) |
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Name for the generated PDF file (max 256 chars) |
html |
string | Yes | Raw HTML content to convert (max 10 MB) |
options |
object | No | PDF generation options (see below) |
Both endpoints support an optional options object:
{
"options": {
"format": "A4",
"printBackground": true,
"margin": {
"top": "1cm",
"right": "1cm",
"bottom": "1cm",
"left": "1cm"
}
}
}| Option | Type | Default | Description |
|---|---|---|---|
format |
string | "A4" |
Paper format: A4, Letter, Legal, A3, A5 |
printBackground |
boolean | true |
Include background colors and images |
margin |
object | 0.4in (~1cm) |
Page margins (see margin units below) |
Margins can be specified with different units:
"0"- No margin (edge-to-edge)"1cm"- Centimeters"10mm"- Millimeters"0.5in"- Inches"96px"- Pixels
Note: If margin is not specified, defaults to 0.4in (~1cm) on all sides.
curl --location 'https://pdf.kreating.dev' \
--header 'Content-Type: application/json' \
--data '{
"name": "report",
"url": "https://example.com/reports/monthly",
"options": {
"format": "Letter",
"printBackground": true,
"margin": {
"top": "2cm",
"right": "1.5cm",
"bottom": "2cm",
"left": "1.5cm"
}
}
}' \
--output report.pdfcurl --location 'https://pdf.kreating.dev/html' \
--header 'Content-Type: application/json' \
--data '{
"name": "certificate",
"html": "<html><body style=\"margin:0;padding:40px;background:linear-gradient(135deg,#667eea,#764ba2);color:white;height:100vh;display:flex;align-items:center;justify-content:center;\"><h1>Certificate of Achievement</h1></body></html>",
"options": {
"format": "A4",
"printBackground": true,
"margin": { "top": "0", "right": "0", "bottom": "0", "left": "0" }
}
}' \
--output certificate.pdfThe API returns binary PDF data. Always use --output to save it to a file.
Success: Returns PDF file with Content-Type: application/pdf
Error: Returns JSON with error message:
{
"error": "Error description"
}| Format | Width | Height |
|---|---|---|
| A4 | 8.27 in | 11.69 in |
| Letter | 8.5 in | 11 in |
| Legal | 8.5 in | 14 in |
| A3 | 11.69 in | 16.54 in |
| A5 | 5.83 in | 8.27 in |