Overview
TheJoyDocExporter component renders a JoyDoc form as a PDF-ready layout. It handles field measurement, formula resolution, and conditional logic — outputting a structure suitable for capturing as a PDF file using a headless browser.
This component is the core building block for self-hosted PDF generation. It takes your JoyDoc JSON data and renders it in a print-optimized format.
1. Install
Using a package manager
2. Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
doc | object | ✅ | — | JoyDoc JSON data containing files and fields arrays. |
theme | object | ✅ | — | Theme configuration. The fontFamily property is required. |
config | object | ❌ | See below | PDF page configuration (height, width, padding). |
Config Object
| Property | Type | Default | Description |
|---|---|---|---|
config.page.height | number | 1056 | Page height in pixels. |
config.page.width | number | 816 | Page width in pixels. |
config.page.padding | number | 0 | Page padding in pixels. |
Theme Object
ThefontFamily property is required. You must also ensure the font is loaded in your application before rendering the exporter.
3. Usage
React
4. PDF Capture Ready
TheJoyDocExporter uses a two-phase rendering process:
- Measurement Phase — The component measures field heights for dynamic layouts (tables, multi-select fields, etc.). During this phase, a “Field Measuring In Progress” message is displayed.
- Render Phase — Once measurements are complete, the final PDF layout is rendered and a
#pdf-capture-readyelement is added to the DOM.
Important: When using a headless browser to capture the PDF, you must wait for the
#pdf-capture-ready element to appear in the DOM before taking a screenshot or generating the PDF. Capturing before this element exists will result in incomplete or missing content.Example: Waiting for PDF Ready (Puppeteer)
5. CSS Requirements
Apply the following styles to the HTML file that contains theJoyDocExporter. This ensures proper color rendering and spacing when generating a PDF.
6. Features
TheJoyDocExporter automatically handles the following when rendering:
- Formula Resolution — All formulas are calculated and resolved before rendering.
- Conditional Logic — Fields are shown or hidden based on configured conditional logic rules.
- Dynamic Field Sizing — Table, collection, and multi-select fields are measured and sized to fit their content.
- Page Breaking — Content is split across pages based on the configured page dimensions.