Lightweight HTTP service that renders HTML or URLs to PDF using Chromium headless shell via Playwright. Runs in Docker with structured JSON logging (pino).
docker compose up -d --build
The service starts on http://localhost:3000.
POST /pdfRender HTML or a URL to PDF.
Request body (JSON):
| Field | Type | Default | Description |
|---|---|---|---|
html | string | — | HTML content to render (provide html or url) |
url | string | — | URL to navigate and render |
format | string | A4 | Page format (A4, Letter, etc.) |
landscape | boolean | false | Landscape orientation |
margin | object | 10mm all sides | { top, right, bottom, left } as CSS values |
waitUntil | string | networkidle | load, domcontentloaded, networkidle, commit |
headers | object | {} | Extra HTTP headers for page navigation |
Response: application/pdf
Example:
curl -X POST http://localhost:3000/pdf \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello World</h1>", "format": "A4"}' \
-o output.pdf
GET /healthReturns service health and stats.
{
"status": "ok",
"browserReady": true,
"uptime": 42.5,
"requestCount": 10,
"launchCount": 1
}
| Variable | Default | Description |
|---|---|---|
PORT | 3000 | Server port |
PAGE_LOAD_TIMEOUT | 30000 | Page load timeout in ms |
CORS_ORIGIN | * | Allowed CORS origin |
LOG_LEVEL | info | Pino log level (debug, info, warn, error) |
NODE_ENV | — | Set to production for raw JSON logs |
├── server.ts # Express server with Playwright PDF rendering
├── Dockerfile # Single-stage build with chromium headless shell
├── docker-compose.yml # Docker Compose config with healthcheck
├── package.json
├── test/
│ └── test.ts # Integration test (health + PDF generation)
└── env.example
# Install dependencies
pnpm install
# Run locally (requires Playwright browsers installed)
pnpm dev
# Run tests (requires service running)
pnpm test
The image uses node:25-slim with only the Chromium headless shell (~110 MB) — no full browser, no Firefox, no WebKit. System dependencies are auto-installed via npx playwright install --with-deps chromium --only-shell.
Content type
Image
Digest
sha256:ec0d0522d…
Size
313.7 MB
Last updated
4 months ago
docker pull nxtgencat/aeropdf