Generate PDFs with cURL

Complete cURL code examples for the PixDoc API

Install

Terminal
# cURL is pre-installed on macOS, Linux, and Windows 10+

Generate a PDF

Send HTML to the /api/v1/pdf endpoint and save the binary response.

cURL
curl -X POST https://pixdoc.dev/api/v1/pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Hello World</h1>"}' \
  -o output.pdf

Take a Screenshot

The /api/v1/screenshot endpoint returns a PNG image.

cURL
curl -X POST https://pixdoc.dev/api/v1/screenshot \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Hello World</h1>"}' \
  -o screenshot.png

Use a Template

Pass a template_id and variables instead of raw HTML.

cURL
curl -X POST https://pixdoc.dev/api/v1/pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": "invoice",
    "variables": {
      "company": "Acme Corp",
      "total": "$1,250.00"
    }
  }' \
  -o invoice.pdf

Next Steps