PDF

Convert HTML or a URL to PDF (PDFShift v3 compatible)

Renders the HTML document or public URL in source with Chromium and returns the PDF. Nothing is stored. Retrying is safe: a render has no side effects and nothing is stored, so a repeated request never creates a duplicate. Retry 408, 429 and 503 with an increasing wait (for example 2, 4 and 8 seconds); do not retry other 4xx errors.

post/v3/convert/pdf

Request

  • Base URL: https://api.sahifa.dev
  • URL: https://api.sahifa.dev/v3/convert/pdf
  • Auth: one of:
    • API key in header X-API-Key
    • HTTP basic

Request body

sourcestring required

http(s) URL or HTML document.

formatstring

A0-A6, Letter, Legal, Tabloid, Ledger, or {width}x{height} such as 210mmx297mm.

landscapeboolean
pagesstring
zoomnumber
use_printboolean
disable_backgroundsboolean
disable_javascriptboolean
delayinteger

Milliseconds.

wait_forstring

Name of a global function that returns truthy when the page is ready.

timeoutinteger

Seconds; capped at 30.

raise_for_statusboolean
cssstring
javascriptstring
http_headersobject
encodeboolean

Return JSON with base64 data.

sandboxboolean

Accepted and ignored.

Example request

{
  "pages": "1,3-5"
}

Response

The PDF, or JSON when encode is true

successboolean
datastring byte
filesizeinteger
durationinteger

Changes

No recorded changes to this operation across all 1 revision of this API.