Generate your first PDF¶
Run PressJet on your machine, send a small HTML document, and save the response as a PDF. The commands below use Docker, OpenSSL, and curl. For a browser-only trial, open the playground. For a local executable, see Install PressJet.
1. Start the API¶
Run both commands in the same terminal so curl can use the same key in the next step.
export PRESSJET_API_KEY="$(openssl rand -hex 32)"
docker run --rm --detach --name pressjet-quickstart \
--publish 127.0.0.1:8080:8080 \
--env PRESSJET_API_KEY \
ghcr.io/tonysantana1492/pressjet:0.1.0-beta.7
Check that the service is ready. A successful response includes "status":"ok".
curl --fail-with-body http://127.0.0.1:8080/health
2. Send an invoice¶
The API accepts populated HTML and returns PDF bytes. Use print CSS to specify page size and margins.
curl --fail --show-error http://127.0.0.1:8080/v1/html \
--header "Authorization: Bearer $PRESSJET_API_KEY" \
--header "Content-Type: application/json" \
--data-binary @- --output invoice.pdf <<'JSON'
{
"version": 1,
"html": "<!doctype html><html lang='en'><head><title>Invoice 42</title><style>@page { size: A4; margin: 20mm; } body { font-family: sans-serif; }</style></head><body><h1>Invoice 42</h1><p>Print production — $120.00</p><p><strong>Total due: $120.00</strong></p></body></html>"
}
JSON
Open invoice.pdf. You should see one A4 page with the invoice title, line item, and total.
3. Use it in your app¶
Send your finished HTML to the API, build a native document from application data, or bind data to a reusable template. See the self-hosting guide when you are ready to operate the service.
When you finish testing, stop the container with docker stop pressjet-quickstart.