HTML to PDF Service

MethodPathDescription
GET/This page
POST/pdfConvert HTML to PDF (JSON body with url or base64 HTML)
GET/serve/:filenameServe a static file from the PDF folder
GET/dashboardUser dashboard
POST/organizationsCreate an organization
POST/auth/registerRegister a new user account
POST/auth/loginLog in and receive a JWT
POST/auth/logoutLog out
GET/auth/meCurrent user info
POST/auth/change-passwordChange password
POST/auth/forgot-passwordRequest a password reset email
POST/auth/reset-passwordReset password with token
GET/auth/verify-emailVerify email address
POST/auth/resend-verificationResend verification email

Pricing

PlanRequests / monthMonthlyYearly
Starter50,000$9.99$99.99
Pro250,000$39.99$399.99
Business1,000,000$99.99$999.99

Get started →

POST /pdf — Usage Examples

The /pdf endpoint accepts a JSON body and returns raw PDF bytes (application/pdf). All requests must include an Authorization: Bearer <token> header.

Request variants

Print options (all optional)

FieldTypeDefaultDescription
landscapeboolfalseLandscape orientation
displayHeaderFooterboolfalseShow Chrome's default header/footer
printBackgroundbooltruePrint background graphics and colors
scalefloat1.0Page scale factor (0.1–2.0)
paperWidthfloat8.27Paper width in inches (A4 default)
paperHeightfloat11.69Paper height in inches (A4 default)
marginTopfloat0.0Top margin in inches
marginBottomfloat0.0Bottom margin in inches
marginLeftfloat0.0Left margin in inches
marginRightfloat0.0Right margin in inches
preferCSSPageSizeboolfalseUse @page CSS size instead of paperWidth/paperHeight

curl

# URL mode — render a public URL
curl -s -X POST https://htmlpdfs.com/pdf \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"url":"https://example.com"}' \
  --output page.pdf

# Data mode — render inline HTML (base64-encoded)
HTML=$(echo -n '<h1>Hello PDF</h1><p>Generated from HTML.</p>' | base64)
curl -s -X POST https://htmlpdfs.com/pdf \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d "{\"data\":\"$HTML\"}" \
  --output page.pdf

# With custom print options (A4 landscape, 0.5 inch margins)
curl -s -X POST https://htmlpdfs.com/pdf \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "url": "https://example.com",
    "options": {
      "landscape": true,
      "printBackground": true,
      "marginTop": 0.5,
      "marginBottom": 0.5,
      "marginLeft": 0.5,
      "marginRight": 0.5
    }
  }' \
  --output page.pdf

Python

import base64
import requests

BASE_URL = "https://htmlpdfs.com"
TOKEN = "YOUR_TOKEN"
HEADERS = {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}

# URL mode
resp = requests.post(f"{BASE_URL}/pdf", headers=HEADERS, json={"url": "https://example.com"})
resp.raise_for_status()
open("page.pdf", "wb").write(resp.content)

# Data mode
html = "<h1>Hello PDF</h1><p>Generated from HTML.</p>"
encoded = base64.b64encode(html.encode()).decode()
resp = requests.post(f"{BASE_URL}/pdf", headers=HEADERS, json={"data": encoded})
resp.raise_for_status()
open("page.pdf", "wb").write(resp.content)

# With options
resp = requests.post(f"{BASE_URL}/pdf", headers=HEADERS, json={
    "url": "https://example.com",
    "options": {
        "landscape": True,
        "printBackground": True,
        "paperWidth": 11.69,   # A4 landscape width
        "paperHeight": 8.27,   # A4 landscape height
        "marginTop": 0.5,
        "marginBottom": 0.5,
        "marginLeft": 0.5,
        "marginRight": 0.5,
    },
})
resp.raise_for_status()
open("page.pdf", "wb").write(resp.content)

JavaScript (Node.js)

const fs = require("fs");

const BASE_URL = "https://htmlpdfs.com";
const TOKEN = "YOUR_TOKEN";
const headers = { Authorization: `Bearer ${TOKEN}`, "Content-Type": "application/json" };

async function htmlToPdf(body, outFile) {
  const res = await fetch(`${BASE_URL}/pdf`, { method: "POST", headers, body: JSON.stringify(body) });
  if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
  fs.writeFileSync(outFile, Buffer.from(await res.arrayBuffer()));
  console.log("Saved", outFile);
}

// URL mode
await htmlToPdf({ url: "https://example.com" }, "page.pdf");

// Data mode
const html = "<h1>Hello PDF</h1><p>Generated from HTML.</p>";
await htmlToPdf({ data: Buffer.from(html).toString("base64") }, "page.pdf");

// With options
await htmlToPdf({
  url: "https://example.com",
  options: {
    landscape: true,
    printBackground: true,
    marginTop: 0.5,
    marginBottom: 0.5,
    marginLeft: 0.5,
    marginRight: 0.5,
  },
}, "page.pdf");

PHP

<?php

$BASE_URL = 'https://htmlpdfs.com';
$TOKEN    = 'YOUR_TOKEN';

function htmlToPdf(string $baseUrl, string $token, array $payload, string $outFile): void {
    $ch = curl_init("$baseUrl/pdf");
    curl_setopt_array($ch, [
        CURLOPT_POST           => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER     => [
            "Content-Type: application/json",
            "Authorization: Bearer $token",
        ],
        CURLOPT_POSTFIELDS     => json_encode($payload),
    ]);
    $pdf = curl_exec($ch);
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if ($code !== 200) throw new \RuntimeException("HTTP $code: $pdf");
    file_put_contents($outFile, $pdf);
}

// URL mode
htmlToPdf($BASE_URL, $TOKEN, ['url' => 'https://example.com'], 'page.pdf');

// Data mode
$html    = '<h1>Hello PDF</h1><p>Generated from HTML.</p>';
$encoded = base64_encode($html);
htmlToPdf($BASE_URL, $TOKEN, ['data' => $encoded], 'page.pdf');

// With options
htmlToPdf($BASE_URL, $TOKEN, [
    'url'     => 'https://example.com',
    'options' => [
        'landscape'      => true,
        'printBackground'=> true,
        'marginTop'      => 0.5,
        'marginBottom'   => 0.5,
        'marginLeft'     => 0.5,
        'marginRight'    => 0.5,
    ],
], 'page.pdf');

Notes for LLM consumers