Version

Document Class

Encapsulates a word processing document.
Syntax
'Declaration
 
Public Class Document 
public class Document 
Remarks

The Document class represents the root level of the object hierarchy. It serves as a container for block-level content such as paragraphs and tables.

Block-level content is contained within the ContentBlocks collection; paragraphs and tables can be added to a document using the AddParagraph and AddTable methods, respectively.

Properties of the document such as author, title, and subject can be specified using the DocumentProperties property.

Default formatting attributes for all content within the document can be defined using the DefaultFont, DefaultParagraphProperties, and DefaultTableProperties properties.

Pagination properties such as page size, page orientation, and margins, can be defined using the FinalSection property and the Sections collection. The FinalSection property returns an object with which the developer can specify pagination properties for the entire document. The Sections collection provides a way to define document sections for groups or block-level content. When the Sections collection contains one or more members, the FinalSection defines the pagination for the block-level content in the document which follows the last block for which a section is explicitly defined.

Headers and footers can also be added to the document, using the HeaderAllPages, FooterAllPages, HeaderFirstPageOnly, and FooterFirstPageOnly properties of the section. Headers and footers can contain the same block-level content as the document itself; content is written to the headers/footers using the identical syntax as is used when writing main document content (headers and footers expose a ContentBlocks collection, which is the same type as the ContentBlocks collection exposed by the Document).

The developer can use the Unit property to change the implied unit of measurement for the property get and set methods at any time during the lifetime of the document without affecting the actual values. For example, when setting font sizes the property can be set to 'Point', and then changed to 'Inch' or 'Centimeter' when setting indentation or line spacing, and any previously set values will remain as they were.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also