Skip to content

SFDT to PDF

This page documents the pure-Dart path used when docx_editor or a backend service converts Syncfusion Document Text (SFDT) JSON into a PDF.

High-Level Flow

text
SFDT JSON string or map
  -> SfdtReader.read / readMap
  -> DocxBuiltDocument
  -> PdfExporter.exportToBytes
  -> PdfLayoutEngine
  -> PdfLayoutDocument / paginated pages
  -> PdfDocumentWriter
  -> PDF bytes

No Syncfusion DocumentEditor web service and no .NET process are required for this path.

Minimal Example

dart
final document = const SfdtReader().read(sfdtJson);
final pdfBytes = PdfExporter(
  creationDate: DateTime.utc(2026, 6, 20),
  strictFonts: true,
).exportToBytes(document);

What SfdtReader Preserves

SfdtReader converts Syncfusion JSON into DocxBuiltDocument.

SFDT areaModel result
sections and blocksDocxSectionDef, DocxSectionBreakBlock, body nodes
paragraphs and runsDocxParagraph, DocxText, tabs, breaks, fields
tablesDocxTable, rows, cells, borders, margins, spans, widths
listsDocxList and numbering data
headers and footerssection furniture
imagesinline or block image nodes with relationship-backed bytes where present
commentsDocxComment and comment anchors where modeled
revisionsDocxRunRevision and revision metadata
protectionprotection type, hash, salt, spin count, enforcement
custom XMLDocxCustomXml parts
document defaultsdefault run style through DocxTheme

What PdfExporter Does

PdfExporter.exportToBytes:

  1. creates a PdfDocumentWriter;
  2. reads w:defaultTabStop from settings XML, falling back to the OOXML default;
  3. splits the document into sections;
  4. appends authored footnotes to the final section using the current simplified end-of-document behavior;
  5. builds a PdfLayoutEngine for each section using page geometry, margins, headers, footers, columns, document grid, and font configuration;
  6. paginates content into pages or builds a PdfLayoutDocument for multi-column layout;
  7. renders page content, furniture, watermarks, images, and text streams;
  8. writes the PDF object graph and returns bytes.

Export Configuration

OptionPurpose
pageWidth, pageHeightDefault page size when the document does not override it.
marginTop, marginBottom, marginLeft, marginRightDefault margins.
fontSizeDefault body font size. The default is 11pt to match Word defaults.
compressContentCompress PDF content streams.
watermarkOptional diagonal watermark on every page.
watermarkColorHexWatermark fill color.
watermarkOpacityWatermark alpha in the PDF graphics state.
creationDateFixed PDF creation timestamp for deterministic output.
strictFontsThrow when a glyph cannot be represented by registered fonts.
registerFontAdd custom font bytes for rendering.

Deterministic Rendering

For controlled workflows, pass a trusted UTC creationDate and enable strictFonts. This avoids client-clock leaks and prevents silent glyph loss in issued PDFs.

dart
final exporter = PdfExporter(
  creationDate: trustedIssuedAt,
  strictFonts: true,
  watermark: 'CONTROLLED',
);

exporter.registerFont('Arial', arialBytes);
final bytes = exporter.exportToBytes(document);

Known Simplification

Footnotes are currently appended to the end of the document with matching markers. They are not yet laid out at the bottom of each page because that would require reserving variable page-bottom space during pagination.