Skip to content

Render and preview PDFs

Use the server from the quickstart. These shell examples use curl, jq, and the same PRESSJET_API_KEY that the server has configured.

Save the final markup as invoice.html and send it to POST /v1/html. The response is PDF bytes.

jq -n --rawfile html invoice.html '{version: 1, html: $html}' |
  curl --fail-with-body http://127.0.0.1:8080/v1/html \
    -H "Authorization: Bearer $PRESSJET_API_KEY" \
    -H 'Content-Type: application/json' \
    --data-binary @- -o invoice.pdf

See fonts and images for explicit assets and HTML for options and limits.

Render a native document

Save this object as render.json. The layout is a native document tree.

{
  "version": 1,
  "layout": {
    "type": "document",
    "properties": { "title": "Invoice 42" },
    "children": [{
      "type": "page",
      "properties": { "size": "A4" },
      "children": [{
        "type": "text",
        "properties": {},
        "children": ["Invoice 42"]
      }]
    }]
  }
}
curl --fail-with-body http://127.0.0.1:8080/v1/generate \
  -H "Authorization: Bearer $PRESSJET_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @render.json -o native.pdf

Get a PNG preview

Add an options object and send the native document to POST /v1/preview. The response is JSON containing both the PDF and page images as base64.

jq '. + {options: {scale: 1, maximumPages: 1}}' render.json |
  curl --fail-with-body http://127.0.0.1:8080/v1/preview \
    -H "Authorization: Bearer $PRESSJET_API_KEY" \
    -H 'Content-Type: application/json' \
    --data-binary @- -o preview.json

For saved templates, send data to the template's render endpoint. Use the durable jobs pilot for a separate job submission and retrieval workflow.