Rendering Diagnostics
Some mistakes never reach the renderer: the payload is checked against the schema first, so a misspelt style key (fontSizr) or a value outside its list (textAlign: "sideways") is refused before anything is drawn, with a message naming it. Others only show while the document is built: a style name nobody declared, a file that is not there, a barcode payload its symbology cannot encode, an inline tag value that cannot be read. For those the engine degrades gracefully and continues, and says so in its render report, whose codes the API returns in the response's errorCodes.
The diagnostics opt-in draws that report inside the rendered document itself. Same pattern the barcode encoder already uses for invalid payloads ([Barcode not drawn - …] drawn in place of the symbol) — extended to styles, files, inline tags and the rest of the report.
Live example
A fixture that walks seven places authors most often go wrong — a style property, a property value, a style reference, an image file, text in another script, an svg shape and inline tags — each written correctly, so it renders with no marker and no appendix. Written wrongly, each would carry a marker below it, and the appendix on the last page would list them.
- Output
- Template
- Data
How to enable
Add a diagnostics block at the document root:
{
"document": {
"diagnostics": {
"showInDocument": "appendix",
"minLevel": "warning"
},
"content": [ { "p": "Report body." } ]
}
}
| Property | Type | Default | Description |
|---|---|---|---|
showInDocument | string | "off" | How to surface diagnostics: off (nothing drawn; the render report and errorCodes still carry every issue), appendix (aggregated table at end of document), inline (marker paragraphs after the block that raised each issue), both (inline markers + appendix). |
minLevel | string | "warning" | Lowest severity to include: info (notes on how a request was carried out, such as a synthesised bold), warning (something substituted or left out), error (something asked for that could not be drawn). |
off only decides what is drawn: the engine produces its report whatever the setting, so errorCodes are the same with diagnostics on or off. Opting in always produces complete diagnostics — nothing else needs to be configured.
What gets captured
Every issue the engine raises while it reads the content and lays it out flows through this surface automatically. Coverage includes:
- References to undeclared styles —
{ "p": "...", "style": "doesNotExist" }. The engine's default style is drawn in its place. Captured as warning. - Files not found or not read — an image (a block
imageor an inline[image]) whose file is not a declared image, not in your files and not beside the document. Captured as error, with the codeIMAGE_NOT_LOADED. - Barcodes that cannot be encoded — a payload its symbology refuses, also drawn as
[Barcode not drawn - …]in place of the symbol. Captured as error. - Inline tag values — an unreadable
[fontcolor]colour or[fontsize]size. Captured as error; the tag and the rejected value are named. - Faces made by synthesis — a bold or italic the family has no file for, drawn by emboldening or slanting the nearest face. Captured as info.
The render report holds more than the document shows. A font file that could not be loaded (FONT_NOT_LOADED), a [font, X] naming an undeclared family, and text no available face covers (GLYPH_NOT_DRAWN) are reported there and in errorCodes, not drawn as markers.
The collector dedupes each distinct failure: an undeclared style applied to 100 paragraphs — or one missing image used in 50 rows — produces ONE entry, not 100. Severity is escalated if the same source reports a stronger issue later, so the appendix reflects the worst case.
Appendix format
When showInDocument is appendix or both, the renderer appends a "Rendering Diagnostics" section on a page of its own at the end of the document. It opens with a line counting its entries ("3 entries collected at or above 'warning'.") and then a table:
| Severity | Source | Property | Message |
|---|---|---|---|
| warning | (engine) | style "headline" is not declared in document.styles; the engine's default style is drawn in its place | |
| error | (engine) | image "images/missing/thermal-plot.png" was not found: it is not a named image, the asset source does not have it, and no such file sits beside the document [IMAGE_NOT_LOADED] | |
| error | (engine) | [fontcolor, zzz] is not a colour |
Severity is color-coded: warnings in dark goldenrod, errors in firebrick, info in slate gray.
Inline markers
When showInDocument is inline or both, a marker paragraph is emitted after the top-level block in which each issue surfaced — whether the issue came from a named style or from the engine (a missing image, an unreadable tag value). Elements don't need a style for their failures to surface. An issue found while the document is read, before its blocks are laid out — a file that is not there, a barcode that cannot be encoded — is marked after the first block. The entries of one source share one marker:
⚠ (engine): style "headline" is not declared in document.styles; the engine's default style is drawn in its place
Each distinct failure is marked once (dedupe), in the natural flow position, so authors see WHERE the problem happened.
Severity levels
| Level | When emitted | Example |
|---|---|---|
info | A note on how the engine carried out what was asked. | A bold synthesised because the family has no bold face. |
warning | Something was substituted or left out. Renderer continued. | An undeclared style, drawn in the engine's default style. |
error | Something asked for could not be drawn. Element skipped or replaced, render continued. | An image file not found, a barcode payload its symbology cannot encode. |
The default minLevel is warning so info-level notes stay quiet unless explicitly enabled.
Nothing else changes
Enabling diagnostics only adds the markers and the appendix — the rest of the render is identical, and the render report and the response's errorCodes are exactly what they are without it. It is an additional surface for authors, not a replacement for the report.
Recommended for
- Authoring environments — IDE / sandbox renders where authors should see their mistakes.
- Pre-production validation — CI render of every template with
showInDocument: "appendix"and a non-empty appendix flagged as a CI failure. - Customer-portal previews — let template authors debug their own definitions without log-diving.
NOT recommended for
- Production renders for end-customers — the appendix is an authoring affordance, not customer-facing content. Default
offis the right setting for delivered documents.
Format parity
Both PDF and DOCX render the same diagnostics shape with the same inline-marker and appendix behavior, and the markers and appendix are composed through each format's regular content pipeline — so their styling matches body content in both outputs.