Document Model
- 4 minutes to read
A document model defines the logical structure of a document reflecting its logical organization and hierarchically groups the logical entities in a document. It is illustrated in the following diagram.
The root of the document model is the object exposing the SubDocument interface. It delivers the basic document functionality that is common for the main document body, header and footer. Specific functionality belongs to its descendant, the Document interface. Use the RichEditControl.Document property to get access to the Document interface.
The document is divided into logical Document.Sections. Each section in a SectionCollection defines its own page settings, such as paper size, page orientation and margins. The SectionPage.PaperKind, SectionPage.Landscape, Section.Page and Section.Margins properties enable you to access these settings.
To insert a section into an arbitrary position, use the Document.InsertSection method.
The section consists of paragraphs. The Paragraph class represents the paragraph entity in the document model. The Section.Paragraphs property of a section gives you a collection of paragraphs in a particular section of a document. If you need to access the collection of paragraphs in a whole document, use the SubDocument.Paragraphs property.
To modify paragraph formatting, you can use either the Paragraph object or the ParagraphProperties interface. The interface is more convenient to use, since it can be easily accessed for a particular document range via the SubDocument.BeginUpdateParagraphs method. Do not forget to call the SubDocument.EndUpdateParagraphs method to finish the modification appropriately.
To insert a paragraph at an arbitrary position, use the ParagraphCollection.Insert method.
The paragraph consists of runs - groups of characters with a uniform format. This is an internal entity, not available via API. Manage the Positions and Ranges instead.
Note
For the specified DocumentPosition, use the ReadOnlyParagraphCollection.Get method to get an encompassing Paragraph, use the Document.GetSection to get an encompassing Section.
The document model also includes entities that do not comprise the hierarchy, such as lists, styles, tables,inline pictures, floating objects (pictures and text boxes), bookmarks, hyperlinks and comments.
Object | Description | Collection containing an object: | Exposed By |
---|---|---|---|
Represented by a specific collection of paragraphs. This collection is composed of items with a NumberingList interface. Each item is an instance of a certain abstract numbering definition, which is represented by an AbstractNumberingList interface. | Document.AbstractNumberingLists | ||
Pertains to a document and belongs to a particular document model. You cannot add the style object from a style collection of one document to the style collection of another document. | |||
Specific structure based on paragraphs. To change the cell content, you should operate with a corresponding paragraph. | |||
Represents the inline picture entity in the document model. Occupies the range equivalent to one character, i.e., the DocumentRange.Length of the range is equal to 1. |
DocumentImageCollection.Insert | ||
Represents floating object (pictures and text boxes) entities in the document model. Anchored to the position, but can be placed anywhere on the page that contains the anchor - within, above and below the main document body. | |||
Represents bookmark entity in the document model. Linked to the position, so the range can have a zero length. | |||
Represents a hyperlink entity in the document model. Can be linked to the bookmark. | |||
Represents a comment entity in the document model. Linked to the document range. Can be nested - one comment can relate to another. In this case, only the parent comment is linked to the document range, whereas the child comment is linked to its parent. |