Dev Utilities
PDF Generation
Generate PDFs from HTML content or URLs.
POST
$0.01/call/v1/tools/pdf/from-htmlUsage
const res = await fetch('https://api.yepapi.com/v1/tools/pdf/from-html', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
html: '<h1>Invoice #123</h1><p>Total: $99.00</p>',
}),
});
const { data } = await res.json();
console.log(data.url); // CDN URL to the generated PDFcurl -X POST https://api.yepapi.com/v1/tools/pdf/from-html \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Invoice #123</h1><p>Total: $99.00</p>"}'Request Body
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
html | string | Yes | HTML content to convert | — |
format | string | No | Page size: a4, letter, legal | "a4" |
landscape | boolean | No | Landscape orientation | false |
margin | object | No | Page margins {top, right, bottom, left} in px | {40, 40, 40, 40} |
Response
{
"ok": true,
"data": {
"url": "https://cdn.yepapi.com/pdf/def456.pdf",
"pages": 1,
"size": 45231,
"expiresAt": "2025-04-30T00:00:00Z"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
ok | boolean | Whether the request succeeded |
data | object | Response payload |
data.url | string | CDN URL to the generated PDF file |
data.pages | number | Total number of pages in the generated PDF |
data.size | number | File size of the PDF in bytes |
data.expiresAt | string | ISO 8601 timestamp when the CDN-hosted PDF expires |
Info
Generated PDFs are hosted on our CDN for 30 days. Download them immediately if you need permanent storage.