📄

HTML → PDF API

Send any HTML payload to our endpoint and receive a temporary link to download a pixel-perfect PDF — rendered by a real browser engine.

$50/mo — Subscribe →

Endpoints

POST https://trilogicppp.com/api/html-to-pdf

Renders HTML to PDF and returns a temporary download link (valid for 1 hour, single-use).

GET https://trilogicppp.com/api/download/:token

Streams the generated PDF. Link expires after 1 hour or upon first download.

Request

Headers

HeaderValue
Content-Typeapplication/json
X-API-KeyYour API key (required if key is configured)

Body (JSON)

FieldTypeDescription
html string Full HTML string to render. Max 5 MB.
options.format string Page format: A4, Letter, A3… Default: A4 (optional)
options.landscape boolean Landscape orientation. Default: false (optional)
options.printBackground boolean Render CSS backgrounds. Default: true (optional)
options.margin object { top, right, bottom, left } — CSS values. Default: 1cm each (optional)

Example Request

curl -X POST https://trilogicppp.com/api/html-to-pdf \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-key" \
  -d '{
    "html": "<!DOCTYPE html><html><body><h1>Hello PDF</h1></body></html>",
    "options": {
      "format": "A4",
      "margin": { "top": "2cm", "bottom": "2cm", "left": "2cm", "right": "2cm" }
    }
  }'

Response

200 OK

{
  "url":        "https://trilogicppp.com/api/download/550e8400-e29b-41d4-a716-...",
  "expires_at": "2026-02-28T14:30:00.000Z",
  "token":      "550e8400-e29b-41d4-a716-446655440000"
}

Errors

StatusMeaning
400Missing or invalid html field
401Missing or invalid API key
404Download token not found or expired
413HTML payload exceeds 5 MB
500Rendering failure — see detail field

Code Samples

JavaScript (fetch)

const res = await fetch('https://trilogicppp.com/api/html-to-pdf', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your-key',
  },
  body: JSON.stringify({ html: '<h1>Hello</h1>' }),
});
const { url } = await res.json();
window.open(url); // opens PDF download

Python (requests)

import requests

r = requests.post(
    'https://trilogicppp.com/api/html-to-pdf',
    headers={'X-API-Key': 'your-key'},
    json={'html': '<h1>Hello</h1>', 'options': {'format': 'A4'}},
)
print(r.json()['url'])  # temporary download link

PHP

$ch = curl_init('https://trilogicppp.com/api/html-to-pdf');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json', 'X-API-Key: your-key'],
    CURLOPT_POSTFIELDS     => json_encode(['html' => '<h1>Hello</h1>']),
]);
$data = json_decode(curl_exec($ch), true);
echo $data['url'];

Try it live