Configuration
vyuh_docx is headless, so it has no global app configuration. Configuration is local to the reader, builder, exporter, layout, and diagnostic APIs that need it.
PDF Export Configuration
final exporter = PdfExporter(
pageWidth: 612,
pageHeight: 792,
marginTop: 72,
marginBottom: 72,
marginLeft: 72,
marginRight: 72,
fontSize: 11,
compressContent: true,
watermark: 'CONTROLLED',
watermarkColorHex: 'D9D9D9',
watermarkOpacity: 0.18,
creationDate: trustedIssuedAt,
strictFonts: true,
);
exporter.registerFont('Arial', arialBytes);
final bytes = exporter.exportToBytes(document);| Option | Default | Purpose |
|---|---|---|
pageWidth | 612.0 | Default page width in points. Used when the document section does not override page geometry. |
pageHeight | 792.0 | Default page height in points. |
marginTop | 72.0 | Default top margin in points. |
marginBottom | 72.0 | Default bottom margin in points. |
marginLeft | 72.0 | Default left margin in points. |
marginRight | 72.0 | Default right margin in points. |
fontSize | 11 | Base font size used when the document has no more specific style. |
compressContent | true | Compress PDF content streams. Disable for raw PDF debugging. |
watermark | null | Optional diagonal watermark across every page. |
watermarkColorHex | D9D9D9 | Watermark fill color without #. |
watermarkOpacity | 0.18 | Watermark alpha from 0 to 1. |
creationDate | wall clock | Fixed PDF creation time for deterministic output. |
strictFonts | false | Throw if text cannot be represented by registered fonts. |
registerFont | none | Register host-supplied font bytes by font family name. |
Layout Engine Configuration
Most callers use PdfExporter, which creates PdfLayoutEngine from section data. Use the layout engine directly for diagnostics or custom rendering.
final layout = PdfLayoutEngine(
pageWidth: 612,
pageHeight: 792,
marginTop: 72,
marginBottom: 72,
marginLeft: 72,
marginRight: 72,
).buildLayoutDocument(document.elements);The exporter also passes section-derived configuration such as header reserve, footer reserve, columns, document grid line pitch, and default tab stop.
Reader Configuration
Readers are intentionally low ceremony:
| Reader | Configuration model |
|---|---|
DocxReader.load(path) | File path only. Reads the DOCX package and resolves relationships, styles, numbering, sections, comments, revisions, and media. |
DocxReader.loadFromBytes(bytes) | Byte payload only. Use this for server, browser, storage, or upload flows. |
SfdtReader.read(json) | SFDT JSON string. |
SfdtReader.readMap(map) | Already-decoded SFDT map. |
HtmlParser / MarkdownParser | Parser object plus source content. |
Builder Configuration
The builder API configures the document through fluent calls and ends with build():
final document = docx()
.h1('Procedure')
.p('Use the approved equipment.')
.table(rows: [
['Step', 'Owner'],
['Review', 'QA'],
])
.build();For lower-level generation, use DocxDocumentBuilder and model classes directly when a typed field is needed before a fluent helper exists.
Exporter Configuration
| Exporter | Configuration |
|---|---|
DocxExporter | Writes the model to DOCX bytes or file. Configuration is mostly document-driven. |
SfdtExporter | Writes the model to Syncfusion JSON. Configuration is document-driven. |
HtmlExporter | Writes HTML output. Configuration is document-driven. |
PdfExporter | Exposes page defaults, compression, watermark, timestamp, and font strictness. |
Deterministic Review Setup
For review tests and controlled rendering, prefer:
final exporter = PdfExporter(
creationDate: DateTime.utc(2026, 6, 20),
strictFonts: true,
compressContent: false,
);compressContent: false makes PDF content streams easier to inspect in tests. creationDate removes wall-clock drift. strictFonts prevents silent glyph loss.