Skip to content

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

APIPurpose
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 groupPublic 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

APIPurpose
DocxBuiltDocumentRoot document object.
DocxNode / DocxBlock / DocxInline / DocxSectionBase model hierarchy for document content.
DocxParagraphParagraph with inline runs and paragraph properties.
DocxTextText run with style, font, color, underline, and positioning fields.
DocxLineBreak / DocxPageBreak / DocxTabExplicit run-level control characters.
DocxList / DocxListItemNumbered or bulleted list structure.
DocxTable / DocxTableRow / DocxTableCellTable structure and authored table layout data.
DocxTableStyle / DocxTablePosition / DocxTableLookTable formatting and positioning metadata.
DocxInlineImage / DocxImageInline and block images.
DocxShape / drawing enumsText boxes, shape presets, anchoring, and wrapping metadata.
DocxSectionDef / DocxSectionBreakBlockPage geometry, headers, footers, columns, and section boundaries.
DocxHeader / DocxFooterSection furniture content.
DocxPageNumber / DocxPageCountPage-number field runs.
DocxComment / comment range nodesComment metadata and anchors.
DocxRunRevision / DocxRevisionTypeTracked-change metadata.
DocxFootnote / DocxEndnote / refsFootnote and endnote content.
DocxTextFormField / dropdown / checkboxForm-field runs.
DocxTableOfContentsTOC block representation.
DocxPageBorders / background imagePage-level visual properties.

Core Types and Enums

APIPurpose
DocxAlignParagraph alignment.
DocxTextAlignmentVertical text alignment.
DocxColorHex and theme-aware color value.
DocxBorder / DocxBorderSideBorder style and border side data.
DocxFontWeight / DocxFontStyleRun font weight and style.
DocxTextDecoration / DocxUnderlineStyleText decoration and underline variants.
DocxHighlightWord highlight palette.
DocxPageOrientation / DocxPageSizePage geometry helpers.
DocxSectionBreakSection break type.
DocxVerticalAlignCell/content vertical alignment.
DocxWidthTypeAuto, absolute, and percentage width types.
DocxHeadingLevelHeading levels used by builders and styles.
measurement extensionsEMU, twip, point, inch, half-point, eighth-point, and percent conversions.
kRendererIdRenderer identity for traceable output.

Drawing, Images, and Tables

APIPurpose
DocxDrawingPositionInline or floating drawing mode.
DocxHorizontalPositionFrom / DocxVerticalPositionFromFloating object positioning reference.
DrawingHAlign / DrawingVAlignFloating object alignment.
DocxTextWrapText wrapping mode around drawings.
DocxShapePresetSupported shape preset values.
DocxShape / DocxShapeBlockInline and block shapes/text boxes.
DocxInlineImage / DocxImageInline and block image nodes.
DocxTableHAnchor / DocxTableVAnchorFloating table anchors.
DocxTableXPositionSpec / DocxTableYPositionSpecFloating table position specs.

Builders

APIPurpose
docx()Fluent document builder entry point.
DocxDocumentBuilderProgrammatic document creation.
DocxCustomXmlCustom XML parts for structured document data.

Import Parsers

APIPurpose
HtmlParser / DocxParserConvert HTML content into document nodes.
MarkdownParserConvert Markdown content into document nodes.

Exporters

APIPurpose
DocxExporterWrite the model to DOCX bytes/files.
SfdtExporterWrite the model to SFDT JSON.
HtmlExporterWrite HTML output.
PdfExporterRender PDF bytes/files.

PDF Layout

APIPurpose
PdfExporterPublic PDF export entry point.
PdfLayoutEngineMeasurement and pagination engine.
PdfLayoutDocumentExplicit page/box layout model.
PdfLayoutPagePage content box and positioned layout boxes.
PdfLayoutBox subclassesParagraph, table, list, image, and shape layout fragments.

PdfExporter Configuration

OptionPurpose
pageWidth, pageHeightDefault page size.
marginTop, marginBottom, marginLeft, marginRightDefault margins.
fontSizeBase body font size.
compressContentCompress PDF content streams.
watermark, watermarkColorHex, watermarkOpacityWatermark text and appearance.
creationDateDeterministic PDF creation timestamp.
strictFontsThrow 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.

APIPurpose
ReaderContextShared DOCX reader state.
RelationshipManager / DocxRelationshipDOCX relationship resolution.
DocxFont / DocxStyle / DocxTheme / ResolvedStyleStyle, font, theme, and resolved style data.
BlockParser / InlineParser / TableParserXML-to-model parser layers.
NumberingParser / SectionParser / StyleParserNumbering, section, and style parser layers.

Utilities

APIPurpose
DocxDocumentDiffCompare document versions.
DocxDiffResult / DocxDiffEntry / DocxTextSegmentStructured diff output for review UIs.
DocxTemplateEngineFill template placeholders.
DocxValidatorValidate document structure.
ContentTypesGeneratorGenerate DOCX content-type metadata.
DocxIdGenerator / DocxIdTrackerStable ID allocation helpers.
XmlUtils / XML extensionsLow-level XML helpers.
kRendererIdRenderer 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);