Rendering and output targets
How DocStudio turns a resolved document tree into HTML and CSS, the screen, print and pdf targets, escaping, whitelisted styles and output adapters.
The resolved document tree
compile produces the resolved document tree (RDT): plain, serializable JSON with no bindings, conditions or repeaters left. It is the single contract between compilation and output. Output adapters depend only on it.
HTML and CSS
render(tree, options) from docstudio/render returns HTML with its CSS. HTML and CSS are the canonical output. The options include target, title, lang, assets and fonts.
| Target | Use |
|---|---|
screen |
A paper sheet for previews |
print |
@page size and margins for the browser print dialog |
pdf |
Input for the PDF service |
Safety
The renderer escapes all text and attribute values, serializes only whitelisted style properties with validated values, never emits raw HTML, and restricts image sources to asset: identifiers and https URLs. Barcodes and QR codes are drawn as SVG by the renderer.
Output adapters
- Browser printing:
printHtmlfromdocstudio/pdf. See browser printing. - Server PDF:
createPdfServicefromdocstudio/server, driven by Playwright and Chromium. See server-side PDF. - Your own: any code that takes HTML can use the renderer output.
Parity
The designer preview, the print output and the PDF all come from the same renderer, so the layout you design is the layout you get. Differences come from the output engine, such as the browser's margin handling, not from a second renderer.