Skip to content

Invoice PNG Preview

Render a realistic image/png preview of an invoice.

Use this endpoint when an AI agent, chat UI, or browser client cannot display or process PDF directly. Use /v1/generate for the final compliant PDF/XML artifact.

Endpoint

POST https://api.thelawin.dev/v1/preview

Request Modes

From /v1/generate

Pass the transaction_hash returned by /v1/generate as transaction_id. The generated PDF is kept in an ephemeral in-memory cache for 1 minute.

json
{
  "transaction_id": "a1b2c3d4e5f67890a1b2c3d4e5f67890",
  "page": 1,
  "dpi": 144
}

From Invoice JSON

Send the same invoice JSON shape as /v1/generate. The API renders a visual PDF first, then rasterizes it to PNG.

json
{
  "template": "minimal",
  "page": 1,
  "dpi": 144,
  "invoice": {
    "number": "RE-2026-001",
    "date": "2026-01-15",
    "seller": { "name": "Acme GmbH", "country": "DE" },
    "buyer": { "name": "Customer AG", "country": "DE" },
    "items": [{ "description": "Service", "quantity": 1, "unit_price": 100 }]
  }
}

Response

The response body is the PNG image directly.

Content-Type: image/png
X-Transaction-Id: a1b2c3d4e5f67890a1b2c3d4e5f67890
X-Preview-Source: cache
X-Preview-Width: 1191
X-Preview-Height: 1684

PNG previews are cached for 10 minutes.

ZUGFeRD 2.4 & Factur-X 1.0.8 compliant