DOM.Elements.Document
Represents the root document element in the Vega DOM.
is the top-level container for all document content and extendsto allow direct composition of sections, pages, and other elements. This class provides access to document-wide settings such as styles, themes, background color, and persistence operations (save/export).
12 members
Constructors
Document
2 overloadsDocument()Initializes a new, emptyinstance.
The document is created in memory and contains no sections by default. Sections can be added using.
Document(string filePath)Initializes a newinstance from an existing file.
This constructor is intended to be used by concrete implementations that load and map external document formats into the Vega DOM.
Parameters
- filePath
- Path to the document file to load.
Properties
Gets or sets the background color of the document pages.
When set, this value is applied at the document level and mapped to the corresponding background representation in the target format (for example, WordprocessingML page background).
Gets or sets the collection of styles associated with this document.
This property provides access to document-level styles, including paragraph styles, character styles, and theme definitions.
Gets the collection of sections contained in this document.
Each section represents a logical division of the document and may define its own page layout, margins, headers, and footers.
Methods
AddSection
2 overloadsIDocumentSection AddSectionCreates and adds a new section to the document.
A default paragraph is automatically added to the new section to ensure it is immediately usable.
Returns
IDocumentSection
The newly created.
IDocumentSection AddSection(IDocumentSection documentSection)Adds an existing section to the document.
Parameters
- documentSection
- The section instance to add.
Returns
IDocumentSection
The addedinstance.
ExportAs
ExportAs(DocumentFileType DestinationFileFormat, string filePath)Exports the document to the specified file format.
This method serves as an extension point for format-specific exporters (such as Word, HTML, or PDF).
Parameters
- DestinationFileFormat
- The target file format for export.
- filePath
- Destination path for the exported file.
GetActiveTheme
ITheme GetActiveThemeGets the currently active theme of the document.
Returns
ITheme
The activeinstance.
Exceptions
- System.Exception: Thrown when no active theme is defined.
Save
2 overloadsSaveSaves the document using the default persistence mechanism.
This method is intended to be overridden by concrete implementations that know how to persist the document to a specific format.
Save(string filePath)Saves the document to the specified file path.
This method is intended to be overridden by concrete implementations that support saving documents to external storage.
Parameters
- filePath
- Destination path where the document will be saved.
SetActiveTheme
SetActiveTheme(string themeName)Sets the active theme for the document by name.
Only one theme can be active at a time. Activating a theme will automatically deactivate all other themes in the document.
Parameters
- themeName
- The name of the theme to activate.
Exceptions
- System.Exception: Thrown when the specified theme does not exist in.