ImportDocumentation Index
Fetch the complete documentation index at: https://pdfn.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
pdfn from @pdfn/react and create a client. It auto-detects your environment — local dev server, pdfn Cloud, or a custom endpoint.
Client setup
pdfn() reads the PDFN_API_KEY environment variable automatically. If set, it connects to pdfn Cloud. If not, it falls back to localhost:3456 for local development.
Client options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | process.env.PDFN_API_KEY | API key for pdfn Cloud or custom server |
baseUrl | string | Auto-detected | Server URL (Cloud if apiKey set, otherwise localhost:3456) |
timeout | number | 30000 | Default request timeout in ms |
generate()
Generates a PDF and returns a buffer. Requires a running pdfn server (local dev server or pdfn Cloud).Generate parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
react | ReactElement | Yes | React component to render and convert to PDF |
debug | DebugOptions | boolean | No | Enable debug overlays (grid, margins, headers, breaks) |
standard | PDFStandard | No | PDF/A or PDF/UA archival standard (pdfn Cloud only) |
filename | string | No | Filename for Content-Disposition header |
metadata | object | No | PDF document metadata (see below) |
idempotencyKey | string | No | Deduplication key — identical keys return cached results |
timeout | number | No | Request timeout in ms (overrides client default) |
Metadata fields
| Field | Type | Description |
|---|---|---|
title | string | Document title (shows in PDF readers) |
author | string | Author name |
subject | string | Document subject |
keywords | string | Keywords for search |
creator | string | Application that created the document |
These fields override the matching props on
<Document>. If you set title on both <Document> and metadata, the metadata value wins.Generate response
Examples
React component with options:render()
Renders a React component to a self-contained HTML string. Runs locally — no server required. Use this when you want to preview HTML or convert to PDF with your own Puppeteer/Playwright setup (see Self-Hosting).Render parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
react | ReactElement | Yes | React component to render to HTML |
debug | DebugOptions | boolean | No | Enable debug overlays |
Render response
Debug options
Bothgenerate() and render() accept a debug option for development overlays:
| Option | Description |
|---|---|
grid | Shows a baseline grid overlay |
margins | Highlights page margins |
headers | Shows header/footer regions |
breaks | Marks page break positions |
Next steps
Troubleshooting
Error codes, common issues, and fixes
Self-Hosting
Run PDF generation on your own infrastructure