Document Class |
Namespace: Aspose.Words
The Document type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | Document |
Creates a blank Word document.
|
![]() ![]() | Document(Stream) |
Opens an existing document from a stream. Automatically detects the file format.
|
![]() ![]() | Document(String) |
Opens an existing document from a file. Automatically detects the file format.
|
![]() ![]() | Document(Stream, LoadOptions) |
Opens an existing document from a stream. Allows to specify additional options such as an encryption password.
|
![]() ![]() | Document(String, LoadOptions) |
Opens an existing document from a file. Allows to specify additional options such as an encryption password.
|
Name | Description | |
---|---|---|
![]() ![]() | AttachedTemplate |
Gets or sets the full path of the template attached to the document.
|
![]() ![]() | AutomaticallyUpdateStyles |
Gets or sets a flag indicating whether the styles in the document are updated to match the styles in the
attached template each time the document is opened in MS Word.
|
![]() ![]() | BackgroundShape |
Gets or sets the background shape of the document. Can be null.
(Inherited from DocumentBase.) |
![]() ![]() | BuiltInDocumentProperties |
Returns a collection that represents all the built-in document properties of the document.
|
![]() ![]() | ChildNodes |
Gets all immediate child nodes of this node.
(Inherited from CompositeNode.) |
![]() ![]() | CompatibilityOptions |
Provides access to document compatibility options (that is, the user preferences entered on the Compatibility
tab of the Options dialog in Word).
|
![]() ![]() | Compliance |
Gets the OOXML compliance version determined from the loaded document content.
Makes sense only for OOXML documents.
|
![]() ![]() | Count |
Gets the number of immediate children of this node.
(Inherited from CompositeNode.) |
![]() ![]() | CustomDocumentProperties |
Returns a collection that represents all the custom document properties of the document.
|
![]() ![]() | CustomXmlParts |
Gets or sets the collection of Custom XML Data Storage Parts.
|
![]() ![]() | DefaultTabStop |
Gets or sets the interval (in points) between the default tab stops.
|
![]() ![]() | DigitalSignatures |
Gets the collection of digital signatures for this document and their validation results.
|
![]() | Document | (Inherited from DocumentBase.) |
![]() ![]() | EndnoteOptions |
Provides options that control numbering and positioning of endnotes in this document.
|
![]() ![]() | FieldOptions |
Gets a FieldOptions object that represents options to control field handling in the document.
|
![]() ![]() | FirstChild |
Gets the first child of the node.
(Inherited from CompositeNode.) |
![]() ![]() | FirstSection |
Gets the first section in the document.
|
![]() ![]() | FontInfos |
Provides access to properties of fonts used in this document.
(Inherited from DocumentBase.) |
![]() ![]() | FontSettings |
Gets or sets document font settings.
|
![]() ![]() | FootnoteOptions |
Provides options that control numbering and positioning of footnotes in this document.
|
![]() ![]() | GlossaryDocument |
Gets or sets the glossary document within this document or template. A glossary document is a storage
for AutoText, AutoCorrect and Building Block entries defined in a document.
|
![]() ![]() | HasChildNodes |
Returns true if this node has any child nodes.
(Inherited from CompositeNode.) |
![]() ![]() | HasMacros |
Returns true if the document has a VBA project (macros).
|
![]() ![]() | HasRevisions |
Returns true if the document has any tracked changes.
|
![]() ![]() | HyphenationOptions |
Provides access to document hyphenation options.
|
![]() ![]() | IsComposite |
Returns true as this node can have child nodes.
(Inherited from CompositeNode.) |
![]() ![]() | LastChild |
Gets the last child of the node.
(Inherited from CompositeNode.) |
![]() ![]() | LastSection |
Gets the last section in the document.
|
![]() ![]() | LayoutOptions |
Gets a LayoutOptions object that represents options to control the layout process of this document.
|
![]() ![]() | Lists |
Provides access to the list formatting used in the document.
(Inherited from DocumentBase.) |
![]() ![]() | MailMerge |
Returns a MailMerge object that represents the mail merge functionality for the document.
|
![]() ![]() | MailMergeSettings |
Gets or sets the object that contains all of the mail merge information for a document.
|
![]() ![]() | NextSibling |
Gets the node immediately following this node.
(Inherited from Node.) |
![]() ![]() | NodeChangingCallback |
Called when a node is inserted or removed in the document.
(Inherited from DocumentBase.) |
![]() ![]() | NodeType |
Returns NodeType.Document.
(Overrides NodeNodeType.) |
![]() ![]() | OriginalFileName |
Gets the original file name of the document.
|
![]() ![]() | OriginalLoadFormat |
Gets the format of the original document that was loaded into this object.
|
![]() ![]() | PackageCustomParts |
Gets or sets the collection of custom parts (arbitrary content) that are linked to the OOXML package using "unknown relationships".
|
![]() ![]() | PageColor |
Gets or sets the page color of the document. This property is a simpler version of BackgroundShape.
(Inherited from DocumentBase.) |
![]() ![]() | PageCount |
Gets the number of pages in the document as calculated by the most recent page layout operation.
|
![]() ![]() | ParentNode |
Gets the immediate parent of this node.
(Inherited from Node.) |
![]() ![]() | PreviousSibling |
Gets the node immediately preceding this node.
(Inherited from Node.) |
![]() ![]() | ProtectionType |
Gets the currently active document protection type.
|
![]() ![]() | Range |
Returns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node.) |
![]() ![]() | RemovePersonalInformation |
Gets or sets a flag indicating that Microsoft Word will remove all user information from comments, revisions and
document properties upon saving the document.
|
![]() ![]() | ResourceLoadingCallback |
Allows to control how external resources are loaded.
(Inherited from DocumentBase.) |
![]() ![]() | Revisions |
Gets a collection of revisions (tracked changes) that exist in this document.
|
![]() ![]() | RevisionsView |
Gets or sets a value indicating whether to work with the original or revised version of a document.
|
![]() ![]() | Sections |
Returns a collection that represents all sections in the document.
|
![]() ![]() | ShadeFormData |
Specifies whether to turn on the gray shading on form fields.
|
![]() ![]() | Styles |
Returns a collection of styles defined in the document.
(Inherited from DocumentBase.) |
![]() ![]() | Theme |
Gets the Theme object for this document.
|
![]() ![]() | TrackRevisions | True if changes are tracked when this document is edited in Microsoft Word.
|
![]() ![]() | Variables |
Returns the collection of variables added to a document or template.
|
![]() ![]() | VbaProject |
Gets or sets a VbaProject.
|
![]() ![]() | VersionsCount |
Gets the number of document versions that was stored in the DOC document.
|
![]() ![]() | ViewOptions |
Provides options to control how the document is displayed in Microsoft Word.
|
![]() ![]() | WarningCallback |
Called during various document processing procedures when an issue is detected that might result
in data or formatting fidelity loss.
(Inherited from DocumentBase.) |
![]() | WebExtensionTaskPanes |
Returns a collection that represents a list of task pane add-ins.
|
![]() ![]() | WriteProtection |
Provides access to the document write protection options.
|
Name | Description | |
---|---|---|
![]() ![]() | Accept |
Accepts a visitor.
(Overrides NodeAccept(DocumentVisitor).) |
![]() ![]() | AcceptAllRevisions |
Accepts all tracked changes in the document.
|
![]() ![]() | AppendChild |
Adds the specified node to the end of the list of child nodes for this node.
(Inherited from CompositeNode.) |
![]() ![]() | AppendDocument(Document, ImportFormatMode) |
Appends the specified document to the end of this document.
|
![]() ![]() | AppendDocument(Document, ImportFormatMode, ImportFormatOptions) |
Appends the specified document to the end of this document.
|
![]() ![]() | Cleanup |
Cleans unused styles and lists from the document.
|
![]() ![]() | Cleanup(CleanupOptions) |
Cleans unused styles and lists from the document depending on given CleanupOptions.
|
![]() ![]() | Clone |
Performs a deep copy of the Document.
|
![]() ![]() | Clone(Boolean) | (Inherited from Node.) |
![]() ![]() | Compare(Document, String, DateTime) |
Compares this document with another document producing changes as number of edit and format revisions Revision.
|
![]() ![]() | Compare(Document, String, DateTime, CompareOptions) |
Compares this document with another document producing changes as a number of edit and format revisions Revision.
Allows to specify comparison options using CompareOptions.
|
![]() ![]() | CopyStylesFromTemplate(String) |
Copies styles from the specified template to a document.
|
![]() ![]() | CopyStylesFromTemplate(Document) |
Copies styles from the specified template to a document.
|
![]() ![]() | EnsureMinimum |
If the document contains no sections, creates one section with one paragraph.
|
![]() | Equals | (Inherited from Object.) |
![]() ![]() | ExpandTableStylesToDirectFormatting |
Converts formatting specified in table styles into direct formatting on tables in the document.
|
![]() ![]() | GetAncestor(Type) |
Gets the first ancestor of the specified object type.
(Inherited from Node.) |
![]() ![]() | GetAncestor(NodeType) |
Gets the first ancestor of the specified NodeType.
(Inherited from Node.) |
![]() ![]() | GetChild |
Returns an Nth child node that matches the specified type.
(Inherited from CompositeNode.) |
![]() ![]() | GetChildNodes |
Returns a live collection of child nodes that match the specified type.
(Inherited from CompositeNode.) |
![]() ![]() | GetEnumerator |
Provides support for the for each style iteration over the child nodes of this node.
(Inherited from CompositeNode.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetPageInfo |
Gets the page size, orientation and other information about a page that might be useful for printing or rendering.
|
![]() ![]() | GetText |
Gets the text of this node and of all its children.
(Inherited from CompositeNode.) |
![]() | GetType | (Inherited from Object.) |
![]() ![]() | ImportNode(Node, Boolean) | Imports a node from another document to the current document. |
![]() ![]() | ImportNode(Node, Boolean, ImportFormatMode) | Imports a node from another document to the current document with an option to control formatting. |
![]() ![]() | IndexOf |
Returns the index of the specified child node in the child node array.
(Inherited from CompositeNode.) |
![]() ![]() | InsertAfter |
Inserts the specified node immediately after the specified reference node.
(Inherited from CompositeNode.) |
![]() ![]() | InsertBefore |
Inserts the specified node immediately before the specified reference node.
(Inherited from CompositeNode.) |
![]() ![]() | JoinRunsWithSameFormatting |
Joins runs with same formatting in all paragraphs of the document.
|
![]() ![]() | NextPreOrder |
Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node.) |
![]() ![]() | NormalizeFieldTypes |
Changes field type values FieldType of FieldStart, FieldSeparator, FieldEnd
in the whole document so that they correspond to the field types contained in the field codes.
|
![]() ![]() | PrependChild |
Adds the specified node to the beginning of the list of child nodes for this node.
(Inherited from CompositeNode.) |
![]() ![]() | PreviousPreOrder |
Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node.) |
![]() ![]() |
Prints the whole document to the default printer.
| |
![]() ![]() | Print(PrinterSettings) |
Prints the document according to the specified printer settings,
using the standard (no User Interface) print controller.
|
![]() ![]() | Print(String) |
Print the whole document to the specified printer,
using the standard (no User Interface) print controller.
|
![]() ![]() | Print(PrinterSettings, String) |
Prints the document according to the specified printer settings,
using the standard (no User Interface) print controller and a document name.
|
![]() ![]() | Protect(ProtectionType) |
Protects the document from changes without changing the existing password or assigns a random password.
|
![]() ![]() | Protect(ProtectionType, String) |
Protects the document from changes and optionally sets a protection password.
|
![]() ![]() | Remove |
Removes itself from the parent.
(Inherited from Node.) |
![]() ![]() | RemoveAllChildren |
Removes all the child nodes of the current node.
(Inherited from CompositeNode.) |
![]() ![]() | RemoveChild |
Removes the specified child node.
(Inherited from CompositeNode.) |
![]() ![]() | RemoveExternalSchemaReferences |
Removes external XML schema references from this document.
|
![]() ![]() | RemoveMacros |
Removes all macros (the VBA project) as well as toolbars and command customizations from the document.
|
![]() ![]() | RemoveSmartTags |
Removes all SmartTag descendant nodes of the current node.
(Inherited from CompositeNode.) |
![]() ![]() | RenderToScale |
Renders a document page into a Graphics object to a specified scale.
|
![]() ![]() | RenderToSize | |
![]() ![]() | Save(String) |
Saves the document to a file. Automatically determines the save format from the extension.
|
![]() ![]() | Save(Stream, SaveFormat) |
Saves the document to a stream using the specified format.
|
![]() ![]() | Save(Stream, SaveOptions) |
Saves the document to a stream using the specified save options.
|
![]() ![]() | Save(String, SaveFormat) |
Saves the document to a file in the specified format.
|
![]() ![]() | Save(String, SaveOptions) |
Saves the document to a file using the specified save options.
|
![]() ![]() | Save(HttpResponse, String, ContentDisposition, SaveOptions) |
Sends the document to the client browser.
|
![]() ![]() | SelectNodes |
Selects a list of nodes matching the XPath expression.
(Inherited from CompositeNode.) |
![]() ![]() | SelectSingleNode |
Selects the first Node that matches the XPath expression.
(Inherited from CompositeNode.) |
![]() ![]() | StartTrackRevisions(String) |
Starts automatically marking all further changes you make to the document programmatically as revision changes.
|
![]() ![]() | StartTrackRevisions(String, DateTime) |
Starts automatically marking all further changes you make to the document programmatically as revision changes.
|
![]() ![]() | StopTrackRevisions |
Stops automatic marking of document changes as revisions.
|
![]() | ToString | (Inherited from Object.) |
![]() ![]() | ToString(SaveFormat) |
Exports the content of the node into a string in the specified format.
(Inherited from Node.) |
![]() ![]() | ToString(SaveOptions) |
Exports the content of the node into a string using the specified save options.
(Inherited from Node.) |
![]() ![]() | UnlinkFields |
Unlinks fields in the whole document.
|
![]() ![]() | Unprotect |
Removes protection from the document regardless of the password.
|
![]() ![]() | Unprotect(String) |
Removes protection from the document if a correct password is specified.
|
![]() ![]() | UpdateFields |
Updates the values of fields in the whole document.
|
![]() ![]() | UpdateListLabels |
Updates list labels for all list items in the document.
|
![]() ![]() | UpdatePageLayout |
Rebuilds the page layout of the document.
|
![]() ![]() | UpdateTableLayout |
Updates widths of cells and tables in the document according to their preferred widths and content.
You do not need to call this method if the tables appear correct in the output document.
|
![]() ![]() | UpdateThumbnail |
Updates Thumbnail of the document using default options.
|
![]() ![]() | UpdateThumbnail(ThumbnailGeneratingOptions) |
Updates Thumbnail of the document according to the specified options.
|
![]() ![]() | UpdateWordCount |
Updates word count properties of the document.
|
![]() ![]() | UpdateWordCount(Boolean) |
Updates word count properties of the document, optionally updates Lines property.
|
The Document is a central object in the Aspose.Words library.
To load an existing document in any of the LoadFormat formats, pass a file name or a stream into one of the Document constructors. To create a blank document, call the constructor without parameters.
Use one of the Save method overloads to save the document in any of the SaveFormat formats.
To draw document pages directly onto a Graphics object use RenderToScale(Int32, Graphics, Single, Single, Single) or RenderToSize(Int32, Graphics, Single, Single, Single, Single) method.
To print the document, use one of the Print(String) methods.
MailMerge is the Aspose.Words's reporting engine that allows to populate reports designed in Microsoft Word with data from various data sources quickly and easily. The data can be from a DataSet, DataTable, DataView, IDataReader or an array of values. MailMerge will go through the records found in the data source and insert them into mail merge fields in the document growing it as necessary.
Document stores document-wide information such as Styles, BuiltInDocumentProperties, CustomDocumentProperties, lists and macros. Most of these objects are accessible via the corresponding properties of the Document.
The Document is a root node of a tree that contains all other nodes of the document. The tree is a Composite design pattern and in many ways similar to XmlDocument. The content of the document can be manipulated freely programmatically:
Consider using DocumentBuilder that simplifies the task of programmatically creating or populating the document tree.
The Document can contain only Section objects.
In Microsoft Word, a valid document needs to have at least one section.
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertField(" MERGEFIELD CustomerName "); builder.InsertParagraph(); builder.InsertField(" MERGEFIELD Address "); // This example creates a table, but you would normally load table from a database DataTable table = new DataTable("Test"); table.Columns.Add("CustomerName"); table.Columns.Add("Address"); table.Rows.Add(new object[] { "Thomas Hardy", "120 Hanover Sq., London" }); table.Rows.Add(new object[] { "Paolo Accorti", "Via Monte Bianco 34, Torino" }); // Field values from the table are inserted into the mail merge fields found in the document doc.MailMerge.Execute(table); doc.Save(ArtifactsDir + "MailMerge.ExecuteDataTable.doc"); // Create a copy of our document to perform another mail merge doc = new Document(); builder = new DocumentBuilder(doc); builder.InsertField(" MERGEFIELD CustomerName "); builder.InsertParagraph(); builder.InsertField(" MERGEFIELD Address "); // We can also source values for a mail merge from a single row in the table doc.MailMerge.Execute(table.Rows[1]); doc.Save(ArtifactsDir + "MailMerge.ExecuteDataTable.OneRow.doc");