DocumentSnapshotBuilder Class
Definition
Builder for creating DocumentSnapshot instances without FlowDocument dependencies. Provides a fluent API for constructing snapshot content.
public class DocumentSnapshotBuilder
Methods
| Name | Description |
|---|---|
| AddBold | Adds bold text to the current paragraph. |
| AddFootnote | Adds a footnote - a nested document snapshot, built with its own builder - paired with the Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.AddFootnoteReference(int) anchor of the same noteId. label is the note's name in a format that addresses notes by name (markdown), or null. Notes are kept in the order added, which readers make the anchor order. |
| AddFootnoteCitation | Adds a further citation of the note noteId already anchored elsewhere: one object replacement character showing that note's number, owning no note of its own. Legal inside a note body, where an anchor is not. |
| AddFootnoteReference | Adds a footnote anchor to the current paragraph: one object replacement character, showing the position of its note among the notes when rendered. noteId pairs it with the Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.AddFootnote(int,Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot,string) body of the same id. |
| AddHyperlink | Adds a hyperlink to the current paragraph. |
| AddImage | No summary available. |
| AddImageReference | Adds an inline image that references an external source (e.g. a URL) instead of embedding pixel bytes. The pixels are resolved at render time by a loader; the document stores only the reference. |
| AddInline | Adds an inline element to the current paragraph. |
| AddItalic | Adds italic text to the current paragraph. |
| AddListItem (3 overloads) | Adds a new empty list item to the current list. |
| AddPageBand | No summary available. |
| AddPageBreak | Applies an explicit page break at the current position. The break is a split instruction, not content: a paragraph with content ends here and continues in a clone of itself, and the next committed block receives Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting.PageBreakBefore. A block that would commit empty while the break is pending is the break's own remainder (or a break-only carrier paragraph) and is dropped - the break carries forward; at a container boundary or the document end the pending break materializes as an empty flagged landing paragraph. |
| AddPageNumberField | Adds a page-number field to the current paragraph. The field's cached result becomes its text content, so plain rendering and export show it until paginated rendering resolves the field per page. |
| AddParagraph (5 overloads) | Adds a new empty paragraph. |
| AddParagraphRange | Registers a paragraph that references a range within previously set bulk text. The text at [offset, offset + length) must already exist in the rope via a prior Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.SetBulkText(ReadOnlyMemory{char}) call. No rope insert is performed; only the snapshot node tree is updated. |
| AddRun | No summary available. |
| AddText (2 overloads) | No summary available. |
| AddUnderline | Adds underlined text to the current paragraph. |
| BeginDeferredTableCells | Switches the current table to deferred finalization: its rows and cells stay editable until Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.EndTable, so a serializer can set each cell's span (and drop merge continuations) once the whole table and its column grid are known. Applies only to the current table; other tables keep the eager path. |
| Build | Builds the DocumentSnapshot. |
| Create (2 overloads) | Creates a new DocumentSnapshotBuilder. |
| DropDeferredTableCell | Marks a deferred cell (a vertical-merge continuation folded into the cell above) so it is not emitted when the table finalizes. |
| EndContainer | Ends the most recent Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.StartContainer(Avalonia.Controls.Documents.TextModel.TextDocumentNodeKind,Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting,Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting) and restores the prior container. |
| EndList | Ends the current list and restores the parent list if nested. |
| EndSection | Ends the current section and adds it as a block to the parent container. |
| EndTable | Ends the current table. |
| EndTableCell | Ends the current table cell. |
| EndTableRow | Ends the current table row. |
| GetDeferredTableRowCellCount | Number of cells emitted so far in a deferred row, or -1 if that row does not exist. A serializer compares this against its own cell count to confirm it can address the cells before applying spans. |
| SetBulkText | No summary available. |
| SetContainerCustomData | Sets Avalonia.Controls.Documents.Serialization.Snapshot.SnapshotNode.CustomData on the active block container. Works with sections, generic containers, list items, and table cells. |
| SetDeferredTableCellSpan | Sets a deferred cell's column and row span by its row index and its cell index within that row (both in emit order). No-op unless deferral is active. |
| SetDocumentFormatMetadata | Sets format-specific metadata for the document root node. Serializers use this to attach round-trip metadata (e.g., DOCX header/footer margins). |
| SetDocumentFormatting | Sets document-level formatting (page margins, etc.). Call before or after adding any content; takes effect at Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.Build time. |
| SetDocumentTextElementFormatting | Sets the document's default text formatting - the font, size, foreground and background every block and inline inherits unless it declares its own. It travels as the root node's Avalonia.Controls.Documents.Serialization.Snapshot.SnapshotNode.TextElementFormatting. |
| SetFootnoteNumberFormat | Sets the footnote numbering format alone, keeping the other document-level formatting; a reader learns the numbering and the page geometry from different places. The anchors added with Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.AddFootnoteReference(int) render their numbers in that format. |
| SetListBlockFormatting | Sets block formatting (e.g. explicit Padding) for the current list container. Only explicitly set properties are stored; auto-computed values (such as the marker column ListNode sizes from the item font) are intentionally omitted and recomputed at render time. |
| SetListFormatMetadata | Sets format-specific metadata for the current list. Serializers use this to attach round-trip metadata. |
| SetListItemFormatMetadata | Sets format-specific metadata for the current list item. Serializers use this to attach round-trip metadata. |
| SetListItemFormatting | Sets formatting for the current list item. |
| SetListItemTextElementFormatting | Sets base-level element formatting for the current list item. |
| SetListMarkerAlignment | Sets how the current list's marker is aligned within its column (Word's w:lvlJc): left starts every marker at the same x, right ends them at the same x with a consistent gap to the content. Shared by every item in the list. |
| SetListMarkerOffset | Sets the current list's marker offset (its hanging indent — how far the marker sits back from the item content). Shared by every item in the list. |
| SetParagraphCustomData | Sets Avalonia.Controls.Documents.Serialization.Snapshot.SnapshotNode.CustomData on the current paragraph. |
| SetParagraphFormatMetadata | Sets format-specific metadata for the current paragraph. Serializers use this to attach round-trip metadata (e.g., RTF twips, DOCX style IDs). |
| SetParagraphFormatting | Sets formatting for the current paragraph, or queues it for the next paragraph. |
| SetParagraphTextElementFormatting | Sets base-level element formatting for the current paragraph. If no paragraph is active, queues it for the next paragraph. |
| SetPendingParagraphFormatting | Queues paragraph formatting for the next paragraph without affecting the current one. |
| SetPendingParagraphTextElementFormatting | Queues base-level element formatting for the next paragraph without affecting the current one. |
| SetRootCapacity | Pre-allocates capacity for the root container based on estimated paragraph count. Reduces array resizes during document construction. Call after SetBulkText when paragraph count can be estimated. |
| SetRowCustomData | Sets extension-specific custom data for the current table row (e.g. the markdown header-row flag). |
| SetRowFormatMetadata | Sets format-specific metadata for the current table row. Serializers use this to attach round-trip metadata (e.g., row borders). |
| SetSectionFormatMetadata | Sets format-specific round-trip metadata on the section currently open via Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.StartSection(Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting,Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting,Avalonia.Controls.Documents.TextModel.Formatting.SectionPageSetup). No effect when the active container is not a section. |
| SetSectionPageBandReferences | Sets the current section's page-band references (indices from Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.AddPageBand(Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot,Avalonia.Controls.Documents.PageBandRole,Avalonia.Controls.Documents.PageBandRule,Guid@,string)). |
| SetSectionPageSetup | Sets the page setup of the section currently open via Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.StartSection(Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting,Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting,Avalonia.Controls.Documents.TextModel.Formatting.SectionPageSetup), replacing any value passed there. For readers whose format declares the setup after the section has started (RTF section control words follow \sect; a DOCX section's sectPr sits on its LAST paragraph). No effect when the active container is not a section. |
| SetTableBlockFormatting | Sets block formatting for the current table. |
| SetTableCellBackground | Sets the background color of the current table cell. |
| SetTableCellBorders | No summary available. |
| SetTableCellSpan | Sets how many grid columns and rows the current table cell spans (Word's w:gridSpan and w:vMerge). Each value is clamped to at least 1; a span of 1 carries nothing, so an un-merged cell stays at the default. |
| SetTableCellTextElementFormatting | Sets base-level element formatting for the current table cell. |
| SetTableCellVerticalAlignment | Sets the vertical alignment of the current table cell's content (Word's w:vAlign). Top is the default. |
| SetTableColumns | No summary available. |
| SetTableFormatMetadata | Sets format-specific metadata for the current table. Serializers use this to attach round-trip metadata (e.g., original column widths). |
| SetTableInteriorBorders | No summary available. |
| SetTableRowHeight | Sets the current table row's minimum height in device-independent pixels (Word's w:trHeight). |
| SetTableRowTextElementFormatting | Sets base-level element formatting for the current table row. |
| StartContainer | Starts a generic block container with an arbitrary Avalonia.Controls.Documents.TextModel.TextDocumentNodeKind. Containers nest: calling Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.StartContainer(Avalonia.Controls.Documents.TextModel.TextDocumentNodeKind,Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting,Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting) while another is active pushes the outer container onto a stack. Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.EndContainer pops it. A container opened while a list item or a table cell is open nests inside it - the blocks added to the container are the container's, and the finished container is added back to the item or cell that enclosed it. |
| StartList | Starts a new list with the specified marker style. When called inside an active list item, automatically nests the new list inside the current item instead of finalizing it. |
| StartNestedList | Starts a nested list inside the current list item. |
| StartSection (2 overloads) | Starts a new section container. Blocks added after this call are placed inside the section until Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.EndSection is called. |
| StartTable | Starts a new table. |
| StartTableCell | Starts a new table cell. |
| StartTableRow | Starts a new table row. |
AddBold Method
Adds bold text to the current paragraph.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddBold(string text)
Parameters
text string
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddFootnote Method
Adds a footnote - a nested document snapshot, built with its own builder - paired
with the Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.AddFootnoteReference(int) anchor of the same noteId.
label is the note's name in a format that addresses notes by
name (markdown), or null. Notes are kept in the order added, which readers make
the anchor order.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddFootnote(int noteId, Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot content, string label)
Parameters
noteId int
content Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot
label string
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddFootnoteCitation Method
Adds a further citation of the note noteId already anchored
elsewhere: one object replacement character showing that note's number, owning
no note of its own. Legal inside a note body, where an anchor is not.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddFootnoteCitation(int noteId)
Parameters
noteId int
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddFootnoteReference Method
Adds a footnote anchor to the current paragraph: one object replacement
character, showing the position of its note among the notes when rendered.
noteId pairs it with the Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder.AddFootnote(int,Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot,string) body of
the same id.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddFootnoteReference(int noteId)
Parameters
noteId int
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddHyperlink Method
Adds a hyperlink to the current paragraph.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddHyperlink(string text, string navigateUri)
Parameters
text string
navigateUri string
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddImage Method
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddImage(ReadOnlyMemory<byte> imageData, string mimeType, double width, double height, string altText)
Parameters
imageData ReadOnlyMemory<byte>
mimeType string
width double
height double
altText string
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddImageReference Method
Adds an inline image that references an external source (e.g. a URL) instead of embedding pixel bytes. The pixels are resolved at render time by a loader; the document stores only the reference.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddImageReference(string sourceUri, string mimeType, double width, double height, string altText)
Parameters
sourceUri string
The image reference URI.
mimeType string
The MIME type, when known; defaults to application/octet-stream.
width double
Display width in device-independent pixels; double.NaN uses the intrinsic pixel size.
height double
Display height in device-independent pixels; double.NaN uses the intrinsic pixel size.
altText string
Optional alternative text describing the image.
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddInline Method
Adds an inline element to the current paragraph.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddInline(Avalonia.Controls.Documents.Serialization.Authoring.InlineDraft inline)
Parameters
inline Avalonia.Controls.Documents.Serialization.Authoring.InlineDraft
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddItalic Method
Adds italic text to the current paragraph.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddItalic(string text)
Parameters
text string
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddListItem overloads
AddListItem Method
Adds a new empty list item to the current list.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddListItem()
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder
AddListItem Method
Adds a new list item with a custom Avalonia.Controls.Documents.TextModel.TextDocumentNodeKind to the current list. The kind must have Avalonia.Controls.Documents.TextModel.NodeKindFlags.Block and Avalonia.Controls.Documents.TextModel.NodeKindFlags.BlockContainer flags.
public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder AddListItem(Avalonia.Controls.Documents.TextModel.TextDocumentNodeKind kind)
Parameters
kind Avalonia.Controls.Documents.TextModel.TextDocumentNodeKind
Returns
Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshotBuilder