HTML to PDF API reference

Base URL: https://api.justapi.tech. This API is in beta: the request shape may still change before general availability, and the changelog will say so.

MethodPathDescriptionModes
POST /v1/pdf/from-html Render HTML or a URL to PDF sync (sync: 58 s per call)

Request

Send html (up to 4 MB) or url (a public http or https page), not both.

{
  "html": "<h1>Invoice #1042</h1><p>Total: $120.00</p>",
  "options": {
    "format": "Letter",
    "margin": "12mm",
    "footer_html": "<div style=\"font-size:9px;width:100%;text-align:center\"><span class=\"pageNumber\"></span> / <span class=\"totalPages\"></span></div>"
  }
}

Options

Option Type Default
format A3, A4, A5, Letter, Legal, Tabloid "A4"
width, height CSS lengths instead of format
landscape boolean false
margin CSS length or {top, right, bottom, left} "10mm"
scale 0.1 to 2 1
page_ranges like "1-3,5" all
print_background boolean true
prefer_css_page_size boolean false
header_html, footer_html HTML up to 20,000 characters none
wait_until load, domcontentloaded, networkidle "networkidle"
wait_for_selector CSS selector none
delay_ms 0 to 10000 0
media "print" or "screen" "print"
viewport_width 320 to 3840 1280
output "url" or "base64" "url"; base64 only for results up to 15 MB

Response

{
  "job_id": "job_...",
  "status": "completed",
  "result": { "url": "https://...", "expires_at": "...", "file_id": "file_...", "bytes": 48213, "content_type": "...", "filename": "..." },
  "stats": { "input_bytes": 51200, "output_bytes": 48213, "duration_ms": 640 },
  "billing": { "charged_micros": 6000, "balance_micros": 4950000 }
}

Billing and failures

$0.006 per call at the first volume tier, whatever the file size. The call is synchronous and all or nothing: an unreadable source, an encrypted PDF, a bad option or a worker failure stores nothing and charges $0.00. See pricing for the volume tiers.

Example

curl https://api.justapi.tech/v1/pdf/from-html \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Invoice #1042</h1><p>Total: $120.00</p>","options":{"format":"Letter","margin":"12mm","footer_html":"<div style=\"font-size:9px;width:100%;text-align:center\"><span class=\"pageNumber\"></span> / <span class=\"totalPages\"></span></div>"}}'

The envelope, error catalog and billing rule are the same across every JustAPI service: see the API reference index and error codes.