BuildE2EBuildE2E
DocsStart Free
UtilitiesGenerate PDF
PDF Endpoints

Generate PDF

Generate PDFs from HTML content or any URL. Pages are rendered using a real browser engine, converted to PDF, and uploaded to cloud storage. Returns a public download URL.
POST/v1/pdf/html
Generate a PDF from HTML content. The HTML is rendered in a browser, printed to PDF, and the resulting file is uploaded to cloud storage.

Request Body

ParameterTypeDescription
htmlrequired
stringComplete HTML content to convert to PDF
title
stringTitle used for the exported filename
pageSize
"A4" | "Letter" | "Legal"Page size. Defaults to "A4"
landscape
booleanLandscape orientation. Defaults to false
margin
objectPage margins with top, right, bottom, left (e.g., "20mm")
printBackground
booleanPrint background graphics and colors. Defaults to true
timeoutMs
numberTimeout in milliseconds (${API_CONFIG.pdf.minTimeoutMs}-${API_CONFIG.pdf.maxTimeoutMs}). Defaults to ${API_CONFIG.pdf.defaultTimeoutMs}

Example Request

curl -X POST https://api.builde2e.com/api/v1/pdf/html \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer uc-YOUR-API-KEY' \
  -d '{
    "html": "<h1>Invoice #123</h1><p>Total: $99.00</p>",
    "title": "invoice-123",
    "pageSize": "A4",
    "landscape": false
  }'

Example Response

json
{
  "success": true,
  "url": "https://storage.builde2e.com/exports/1706745600000-quarterly-report.pdf",
  "durationMs": 2340,
  "cost": 0.004
}
POST/v1/pdf/url
Navigate to a URL with a real browser, render the page, and convert it to PDF. Useful for generating PDFs from live webpages, invoices, reports, or dashboards.

Request Body

ParameterTypeDescription
urlrequired
stringURL to navigate to and convert to PDF
title
stringTitle used for the exported filename
pageSize
"A4" | "Letter" | "Legal"Page size. Defaults to "A4"
landscape
booleanLandscape orientation. Defaults to false
margin
objectPage margins with top, right, bottom, left (e.g., "20mm")
printBackground
booleanPrint background graphics and colors. Defaults to true
timeoutMs
numberTimeout in milliseconds (${API_CONFIG.pdf.minTimeoutMs}-${API_CONFIG.pdf.maxTimeoutMs}). Defaults to ${API_CONFIG.pdf.defaultTimeoutMs}

Example Request

curl -X POST https://api.builde2e.com/api/v1/pdf/url \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer uc-YOUR-API-KEY' \
  -d '{
    "url": "https://example.com/invoice/123",
    "title": "invoice-123",
    "pageSize": "Letter",
    "landscape": false
  }'

Example Response

json
{
  "success": true,
  "url": "https://storage.builde2e.com/exports/1706745600000-invoice-123.pdf",
  "durationMs": 3120,
  "cost": 0.004
}

Response Fields

FieldTypeDescription
successbooleanWhether PDF generation succeeded
urlstringPublic download URL of the generated PDF
errorstringError message if generation failed
durationMsnumberTotal time taken in milliseconds
costnumberCost of the request in USD

Margin Object

The margin parameter accepts an object with CSS-style margin values:
FieldTypeDescription
topstringTop margin (e.g., "20mm", "1in")
rightstringRight margin
bottomstringBottom margin
leftstringLeft margin

Error Response

When PDF generation fails, the response will include success: false with an error message:
json
{
  "success": false,
  "error": "Navigation to URL timed out after 30000ms",
  "durationMs": 30150
}