Preview & PDF
How the PDF is produced, exactly which part of it is exact, and when to render it on your own server instead.
Preview
Preview opens a modal dialog containing a real PDF, rendered at that moment and shown in the browser’s own PDF viewer. It is not a chrome-free view of the canvas — it is the finished file.
How the PDF is made
There is one built-in path, and it does something unusual that is worth understanding, because it determines exactly what you can promise.
It runs entirely in the browser. No server, no headless Chromium, nothing to install — so it works on localhost, in the cloud, and on shared hosting.
What is exact
What is approximated
Everything else is a faithful reconstruction, and must never be described as exact.
| Thing | What happens |
|---|---|
| Fonts | Mapped to the 14 standard PDF families — Helvetica, Times, Courier. A custom webfont's metrics are approximated, not embedded, so line lengths can differ slightly. |
| Gradients | Collapse to their first colour. A PDF fill is one colour. |
| Anything outside box, text and image | Not captured. Shadows, for instance, are not drawn. |
Rendering on your server
onRenderPdf replaces the built-in path entirely with an engine you already run.
The returned file is what the preview shows and what the user downloads. Reach for it when:
- the output must be produced with no user present — a nightly batch, a webhook;
- you need embedded custom fonts or effects the capture cannot express;
- you need a real browser engine, or PDF/A, or digital signing.
"Content did not fit"
If a block is genuinely wider or taller than the printable area, the capture reports it rather than silently cropping. A tolerance of one point separates real overflow from sub-point rounding, so the warning means something when you see it.
| Usual cause | Fix |
|---|---|
| An image larger than the column | Set a width, or a fit mode, on the image block. |
| A table with too many columns | Hide columns, or switch the page to landscape. |
| Margins too large for the content | Reduce the page margin. |
| An unbreakable block taller than a page | Turn off keepTogether for it. |
Getting a better PDF
onUploadImage.
The canvas then reserves the right space before the image loads, so nothing reflows mid-capture.
ctx.printing in custom blocks to drop editor hints — but keep the size.
Removing the element instead changes the layout between the canvas and the PDF, and an
unfilled slot should simply print blank.