API Reference
High-use public APIs exported by package:vyuh_docx/vyuh_docx.dart.
Use this page as the package-level API map. The root reviewer pages cover architecture, SFDT to PDF, and rendering capabilities.
Readers
| API | Purpose |
|---|---|
DocxReader.load(path) | Load a DOCX from the file system. |
DocxReader.loadFromBytes(bytes) | Load a DOCX from bytes. |
SfdtReader.read(sfdtJson) | Read Syncfusion Document Text JSON into the document model. |
SfdtReader.readMap(sfdtMap) | Read an already-decoded SFDT map. |
Public Export Groups
package:vyuh_docx/vyuh_docx.dart exports these groups:
| Export group | Public surface |
|---|---|
src/ast/* | Document nodes: paragraphs, text, tables, lists, images, shapes, comments, revisions, sections, raw XML, TOC, footnotes, page borders, background images. |
src/builder/* | docx() and DocxDocumentBuilder for generated documents and custom XML. |
src/core/* | Defaults, enums, exceptions, measurement conversions, renderer id, XML extensions. |
src/diff/* | Document diff model and compare engine. |
src/exporters/* | DOCX, SFDT, HTML, PDF, layout engine, and layout model. |
src/template/* | Template token substitution. |
src/parsers/* | HTML and Markdown import. |
src/reader/docx_reader/* | DOCX package reader, relationships, styles, theme, numbering, sections, block/inline/table parsers. |
src/utils/* | Content types, id generation, validation, XML helpers. |
Document Model
| API | Purpose |
|---|---|
DocxBuiltDocument | Root document object. |
DocxNode / DocxBlock / DocxInline / DocxSection | Base model hierarchy for document content. |
DocxParagraph | Paragraph with inline runs and paragraph properties. |
DocxText | Text run with style, font, color, underline, and positioning fields. |
DocxLineBreak / DocxPageBreak / DocxTab | Explicit run-level control characters. |
DocxList / DocxListItem | Numbered or bulleted list structure. |
DocxTable / DocxTableRow / DocxTableCell | Table structure and authored table layout data. |
DocxTableStyle / DocxTablePosition / DocxTableLook | Table formatting and positioning metadata. |
DocxInlineImage / DocxImage | Inline and block images. |
DocxShape / drawing enums | Text boxes, shape presets, anchoring, and wrapping metadata. |
DocxSectionDef / DocxSectionBreakBlock | Page geometry, headers, footers, columns, and section boundaries. |
DocxHeader / DocxFooter | Section furniture content. |
DocxPageNumber / DocxPageCount | Page-number field runs. |
DocxComment / comment range nodes | Comment metadata and anchors. |
DocxRunRevision / DocxRevisionType | Tracked-change metadata. |
DocxFootnote / DocxEndnote / refs | Footnote and endnote content. |
DocxTextFormField / dropdown / checkbox | Form-field runs. |
DocxTableOfContents | TOC block representation. |
DocxPageBorders / background image | Page-level visual properties. |
Core Types and Enums
| API | Purpose |
|---|---|
DocxAlign | Paragraph alignment. |
DocxTextAlignment | Vertical text alignment. |
DocxColor | Hex and theme-aware color value. |
DocxBorder / DocxBorderSide | Border style and border side data. |
DocxFontWeight / DocxFontStyle | Run font weight and style. |
DocxTextDecoration / DocxUnderlineStyle | Text decoration and underline variants. |
DocxHighlight | Word highlight palette. |
DocxPageOrientation / DocxPageSize | Page geometry helpers. |
DocxSectionBreak | Section break type. |
DocxVerticalAlign | Cell/content vertical alignment. |
DocxWidthType | Auto, absolute, and percentage width types. |
DocxHeadingLevel | Heading levels used by builders and styles. |
| measurement extensions | EMU, twip, point, inch, half-point, eighth-point, and percent conversions. |
kRendererId | Renderer identity for traceable output. |
Drawing, Images, and Tables
| API | Purpose |
|---|---|
DocxDrawingPosition | Inline or floating drawing mode. |
DocxHorizontalPositionFrom / DocxVerticalPositionFrom | Floating object positioning reference. |
DrawingHAlign / DrawingVAlign | Floating object alignment. |
DocxTextWrap | Text wrapping mode around drawings. |
DocxShapePreset | Supported shape preset values. |
DocxShape / DocxShapeBlock | Inline and block shapes/text boxes. |
DocxInlineImage / DocxImage | Inline and block image nodes. |
DocxTableHAnchor / DocxTableVAnchor | Floating table anchors. |
DocxTableXPositionSpec / DocxTableYPositionSpec | Floating table position specs. |
Builders
| API | Purpose |
|---|---|
docx() | Fluent document builder entry point. |
DocxDocumentBuilder | Programmatic document creation. |
DocxCustomXml | Custom XML parts for structured document data. |
Import Parsers
| API | Purpose |
|---|---|
HtmlParser / DocxParser | Convert HTML content into document nodes. |
MarkdownParser | Convert Markdown content into document nodes. |
Exporters
| API | Purpose |
|---|---|
DocxExporter | Write the model to DOCX bytes/files. |
SfdtExporter | Write the model to SFDT JSON. |
HtmlExporter | Write HTML output. |
PdfExporter | Render PDF bytes/files. |
PDF Layout
| API | Purpose |
|---|---|
PdfExporter | Public PDF export entry point. |
PdfLayoutEngine | Measurement and pagination engine. |
PdfLayoutDocument | Explicit page/box layout model. |
PdfLayoutPage | Page content box and positioned layout boxes. |
PdfLayoutBox subclasses | Paragraph, table, list, image, and shape layout fragments. |
PdfExporter Configuration
| Option | Purpose |
|---|---|
pageWidth, pageHeight | Default page size. |
marginTop, marginBottom, marginLeft, marginRight | Default margins. |
fontSize | Base body font size. |
compressContent | Compress PDF content streams. |
watermark, watermarkColorHex, watermarkOpacity | Watermark text and appearance. |
creationDate | Deterministic PDF creation timestamp. |
strictFonts | Throw on missing glyph support. |
registerFont(fontFamily, bytes) | Register host-supplied font bytes. |
DOCX Reader Internals
These are public because renderer diagnostics and migration tests sometimes need to inspect the reader stack.
| API | Purpose |
|---|---|
ReaderContext | Shared DOCX reader state. |
RelationshipManager / DocxRelationship | DOCX relationship resolution. |
DocxFont / DocxStyle / DocxTheme / ResolvedStyle | Style, font, theme, and resolved style data. |
BlockParser / InlineParser / TableParser | XML-to-model parser layers. |
NumberingParser / SectionParser / StyleParser | Numbering, section, and style parser layers. |
Utilities
| API | Purpose |
|---|---|
DocxDocumentDiff | Compare document versions. |
DocxDiffResult / DocxDiffEntry / DocxTextSegment | Structured diff output for review UIs. |
DocxTemplateEngine | Fill template placeholders. |
DocxValidator | Validate document structure. |
ContentTypesGenerator | Generate DOCX content-type metadata. |
DocxIdGenerator / DocxIdTracker | Stable ID allocation helpers. |
XmlUtils / XML extensions | Low-level XML helpers. |
kRendererId | Renderer identity used for traceable deterministic output. |
Common Snippets
dart
final document = const SfdtReader().read(sfdtJson);
final pdf = PdfExporter(
creationDate: DateTime.utc(2026, 6, 20),
strictFonts: true,
).exportToBytes(document);dart
final document = await DocxReader.loadFromBytes(docxBytes);
final sfdt = const SfdtExporter().exportToJson(document);dart
final layout = PdfLayoutEngine(
pageWidth: 612,
pageHeight: 792,
).buildLayoutDocument(document.elements);
print(layout.pageCount);