java.lang.ObjectNode
CompositeNode
DocumentBase
com.aspose.words.Document
public class Document
The Document is a central object in the Aspose.Words library. To load an existing document in any of the Use one of the Save method overloads to save the document in any of the
To draw document pages directly onto a Graphics object use
To print the document, use one of the Document stores document-wide information such as 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 The Document can contain only In Microsoft Word, a valid document needs to have at least one section.
Constructor Summary |
---|
Document()
Creates a blank Word document. |
Document(java.lang.String fileName)
Opens an existing document from a file. Automatically detects the file format. |
Document(java.lang.String fileName, LoadOptions loadOptions)
Opens an existing document from a file. Allows to specify additional options such as an encryption password. |
Document(java.io.InputStream stream)
Opens an existing document from a stream. Automatically detects the file format. |
Document(java.io.InputStream stream, LoadOptions loadOptions)
Opens an existing document from a stream. Allows to specify additional options such as an encryption password. |
Property Getters/Setters Summary | ||
---|---|---|
java.lang.String | getAttachedTemplate() | |
void | setAttachedTemplate(java.lang.String value) | |
Gets or sets the full path of the template attached to the document. | ||
boolean | getAutomaticallyUpdateSyles() | |
void | setAutomaticallyUpdateSyles(boolean value) | |
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. | ||
Shape | getBackgroundShape() | → inherited from DocumentBase |
void | setBackgroundShape(Shape value) | |
Gets or sets the background shape of the document. Can be null. | ||
Aspose.Words.Properties.BuiltInDocumentProperties | getBuiltInDocumentProperties() | |
Returns a collection that represents all the built-in document properties of the document. | ||
NodeCollection | getChildNodes() | → inherited from CompositeNode |
Gets all immediate child nodes of this node. | ||
Aspose.Words.Settings.CompatibilityOptions | getCompatibilityOptions() | |
Provides access to document compatibility options (that is, the user preferences entered on the Compatibility tab of the Options dialog in Word). | ||
Aspose.Words.Saving.OoxmlCompliance | getCompliance() | |
Gets the OOXML compliance version determined from the loaded document content. Makes sense only for OOXML documents. | ||
int | getCount() | → inherited from CompositeNode |
Gets the number of immediate children of this node. | ||
Aspose.Words.Properties.CustomDocumentProperties | getCustomDocumentProperties() | |
Returns a collection that represents all the custom document properties of the document. | ||
Aspose.Words.Markup.CustomXmlPartCollection | getCustomXmlParts() | |
Gets or sets the collection of Custom XML Data Storage Parts. | ||
double | getDefaultTabStop() | |
void | setDefaultTabStop(double value) | |
Gets or sets the interval (in points) between the default tab stops. | ||
DigitalSignatureCollection | getDigitalSignatures() | |
Gets the collection of digital signatures for this document and their validation results. | ||
DocumentBase | getDocument() | → inherited from Node |
Gets the document to which this node belongs. | ||
EndnoteOptions | getEndnoteOptions() | |
Provides options that control numbering and positioning of endnotes in this document. | ||
Aspose.Words.Fields.FieldOptions | getFieldOptions() | |
Gets a FieldOptions object that represents options to control field handling in the document. | ||
Node | getFirstChild() | → inherited from CompositeNode |
Gets the first child of the node. | ||
Section | getFirstSection() | |
Gets the first section in the document. | ||
Aspose.Words.Fonts.FontInfoCollection | getFontInfos() | → inherited from DocumentBase |
Provides access to properties of fonts used in this document. | ||
Aspose.Words.Fonts.FontSettings | getFontSettings() | |
Gets or sets document font settings. | ||
FootnoteOptions | getFootnoteOptions() | |
Provides options that control numbering and positioning of footnotes in this document. | ||
GlossaryDocument | getGlossaryDocument() | |
void | setGlossaryDocument(GlossaryDocument value) | |
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. | ||
boolean | hasChildNodes() | → inherited from CompositeNode |
Returns true if this node has any child nodes. | ||
boolean | hasMacros() | |
Returns true if the document has a VBA project (macros). | ||
boolean | hasRevisions() | |
Returns true if the document has any tracked changes. | ||
Aspose.Words.Settings.HyphenationOptions | getHyphenationOptions() | |
Provides access to document hyphenation options. | ||
boolean | isComposite() | → inherited from CompositeNode |
Returns true as this node can have child nodes. | ||
Node | getLastChild() | → inherited from CompositeNode |
Gets the last child of the node. | ||
Section | getLastSection() | |
Gets the last section in the document. | ||
Aspose.Words.Layout.LayoutOptions | getLayoutOptions() | |
Gets a LayoutOptions object that represents options to control the layout process of this document. | ||
Aspose.Words.Lists.ListCollection | getLists() | → inherited from DocumentBase |
Provides access to the list formatting used in the document. | ||
Aspose.Words.MailMerging.MailMerge | getMailMerge() | |
Returns a MailMerge object that represents the mail merge functionality for the document. | ||
Aspose.Words.Settings.MailMergeSettings | getMailMergeSettings() | |
Gets or sets the object that contains all of the mail merge information for a document. | ||
Node | getNextSibling() | → inherited from Node |
Gets the node immediately following this node. | ||
INodeChangingCallback | getNodeChangingCallback() | → inherited from DocumentBase |
void | setNodeChangingCallback(INodeChangingCallback value) | |
Called when a node is inserted or removed in the document. | ||
int | getNodeType() | |
Returns NodeType.Document. The value of the property is NodeType integer constant. | ||
java.lang.String | getOriginalFileName() | |
Gets the original file name of the document. | ||
int | getOriginalLoadFormat() | |
Gets the format of the original document that was loaded into this object. The value of the property is LoadFormat integer constant. | ||
Aspose.Words.Markup.CustomPartCollection | getPackageCustomParts() | |
Gets or sets the collection of custom parts (arbitrary content) that are linked to the OOXML package using "unknown relationships". | ||
java.awt.Color | getPageColor() | → inherited from DocumentBase |
Gets or sets the page color of the document. This property is a simpler version of |
||
int | getPageCount() | |
Gets the number of pages in the document as calculated by the most recent page layout operation. | ||
CompositeNode | getParentNode() | → inherited from Node |
Gets the immediate parent of this node. | ||
Node | getPreviousSibling() | → inherited from Node |
Gets the node immediately preceding this node. | ||
int | getProtectionType() | |
Gets the currently active document protection type. The value of the property is ProtectionType integer constant. | ||
Range | getRange() | → inherited from Node |
Returns a Range object that represents the portion of a document that is contained in this node. | ||
Aspose.Words.Loading.IResourceLoadingCallback | getResourceLoadingCallback() | → inherited from DocumentBase |
Allows to control how external resources are loaded. | ||
RevisionCollection | getRevisions() | |
Gets a collection of revisions (tracked changes) that exist in this document. | ||
SectionCollection | getSections() | |
Returns a collection that represents all sections in the document. | ||
boolean | getShadeFormData() | |
void | setShadeFormData(boolean value) | |
Specifies whether to turn on the gray shading on form fields. | ||
StyleCollection | getStyles() | → inherited from DocumentBase |
Returns a collection of styles defined in the document. | ||
Aspose.Words.Themes.Theme | getTheme() | |
Gets the |
||
boolean | getTrackRevisions() | |
void | setTrackRevisions(boolean value) | |
True if changes are tracked when this document is edited in Microsoft Word. | ||
VariableCollection | getVariables() | |
Returns the collection of variables added to a document or template. | ||
int | getVersionsCount() | |
Gets the number of document versions that was stored in the DOC document. | ||
Aspose.Words.Settings.ViewOptions | getViewOptions() | |
Provides options to control how the document is displayed in Microsoft Word. | ||
IWarningCallback | getWarningCallback() | → inherited from DocumentBase |
void | setWarningCallback(IWarningCallback value) | |
Called during various document processing procedures when an issue is detected that might result in data or formatting fidelity loss. | ||
Aspose.Words.Settings.WriteProtection | getWriteProtection() | |
Provides access to the document write protection options. |
Method Summary | ||
---|---|---|
boolean | accept(DocumentVisitor visitor) | |
Accepts a visitor. | ||
void | acceptAllRevisions() | |
Accepts all tracked changes in the document. | ||
Node | appendChild(Node newChild) | → inherited from CompositeNode |
Adds the specified node to the end of the list of child nodes for this node. | ||
void | appendDocument(Document srcDoc, int importFormatMode) | |
Appends the specified document to the end of this document. | ||
void | cleanup() | |
Cleans unused styles and lists from the document. | ||
void | cleanup(CleanupOptions options) | |
Cleans unused styles and lists from the document depending on given |
||
void | clearSectionAttrs() | |
Reserved for internal use. | ||
void | compare(Document document, java.lang.String author, java.util.Date dateTime) | |
Compares this document with another document producing changes as number of edit and format revisions |
||
void | compare(Document document, java.lang.String author, java.util.Date dateTime, CompareOptions options) | |
Compares this document with another document producing changes as a number of edit and format revisions |
||
Document | deepClone() | |
Performs a deep copy of the |
||
Node | deepClone(boolean isCloneChildren) | → inherited from Node |
Creates a duplicate of the node. | ||
void | ensureMinimum() | |
If the document contains no sections, creates one section with one paragraph. | ||
void | expandTableStylesToDirectFormatting() | |
Converts formatting specified in table styles into direct formatting on tables in the document. | ||
java.lang.Object | fetchInheritedSectionAttr(int key) | |
Reserved for internal use. | ||
CompositeNode | getAncestor(int ancestorType) | → inherited from Node |
Gets the first ancestor of the specified |
||
CompositeNode | getAncestor(java.lang.Class ancestorType) | → inherited from Node |
Gets the first ancestor of the specified object type. | ||
Node | getChild(int nodeType, int index, boolean isDeep) | → inherited from CompositeNode |
Returns an Nth child node that matches the specified type. | ||
NodeCollection | getChildNodes(int nodeType, boolean isDeep) | → inherited from CompositeNode |
Returns a live collection of child nodes that match the specified type. | ||
CompositeNode | getContainer() | → inherited from CompositeNode |
Reserved for internal use. | ||
java.lang.Object | getDirectSectionAttr(int key) | |
Reserved for internal use. | ||
Node | getNextMatchingNode(aspose.obfuscated.type curNode) | → inherited from CompositeNode |
Reserved for internal use. | ||
Aspose.Words.Rendering.PageInfo | getPageInfo(int pageIndex) | |
Gets the page size, orientation and other information about a page that might be useful for printing or rendering. | ||
java.lang.String | getText() | → inherited from CompositeNode |
Gets the text of this node and of all its children. | ||
Node | importNode(Node srcNode, boolean isImportChildren) | → inherited from DocumentBase |
Imports a node from another document to the current document. |
||
Node | importNode(Node srcNode, boolean isImportChildren, int importFormatMode) | → inherited from DocumentBase |
Imports a node from another document to the current document with an option to control formatting. |
||
int | indexOf(Node child) | → inherited from CompositeNode |
Returns the index of the specified child node in the child node array. | ||
Node | insertAfter(Node newChild, Node refChild) | → inherited from CompositeNode |
Inserts the specified node immediately after the specified reference node. | ||
Node | insertBefore(Node newChild, Node refChild) | → inherited from CompositeNode |
Inserts the specified node immediately before the specified reference node. | ||
void | invalidateFieldTypes() | |
Changes field type values |
||
java.util.Iterator | iterator() | → inherited from CompositeNode |
Provides support for the for each style iteration over the child nodes of this node. | ||
int | joinRunsWithSameFormatting() | |
Joins runs with same formatting in all paragraphs of the document. | ||
Node | nextPreOrder(Node rootNode) | → inherited from Node |
Gets next node according to the pre-order tree traversal algorithm. | ||
void | normalizeFieldTypes() | |
Changes field type values |
||
Node | prependChild(Node newChild) | → inherited from CompositeNode |
Adds the specified node to the beginning of the list of child nodes for this node. | ||
Node | previousPreOrder(Node rootNode) | → inherited from Node |
Gets the previous node according to the pre-order tree traversal algorithm. | ||
void | protect(int type) | |
Protects the document from changes without changing the existing password or assigns a random password. | ||
void | protect(int type, java.lang.String password) | |
Protects the document from changes and optionally sets a protection password. | ||
void | remove() | → inherited from Node |
Removes itself from the parent. | ||
void | removeAllChildren() | → inherited from CompositeNode |
Removes all the child nodes of the current node. | ||
Node | removeChild(Node oldChild) | → inherited from CompositeNode |
Removes the specified child node. | ||
void | removeExternalSchemaReferences() | |
Removes external XML schema references from this document. | ||
void | removeMacros() | |
Removes all macros (the VBA project) as well as toolbars and command customizations from the document. | ||
void | removeSmartTags() | → inherited from CompositeNode |
Removes all |
||
void | removeUnusedResources() | |
Cleans unused resources from the document. | ||
void | save(java.io.OutputStream outputStream, com.aspose.words.SaveOptions saveOptions) | |
Saves the document to a stream using the specified save options. | ||
void | save(java.io.OutputStream outputStream, int saveFormat) | |
Saves the document to a stream using the specified format. | ||
Aspose.Words.Saving.SaveOutputParameters | save(java.lang.String fileName) | |
Saves the document to a file. Automatically determines the save format from the extension. | ||
Aspose.Words.Saving.SaveOutputParameters | save(java.lang.String fileName, int saveFormat) | |
Saves the document to a file in the specified format. | ||
NodeList | selectNodes(java.lang.String xpath) | → inherited from CompositeNode |
Selects a list of nodes matching the XPath expression. | ||
Node | selectSingleNode(java.lang.String xpath) | → inherited from CompositeNode |
Selects the first Node that matches the XPath expression. | ||
void | setSectionAttr(int key, java.lang.Object value) | |
Reserved for internal use. | ||
void | startTrackRevisions(java.lang.String author) | |
Starts automatically marking all further changes you make to the document programmatically as revision changes. | ||
void | startTrackRevisions(java.lang.String author, java.util.Date dateTime) | |
Starts automatically marking all further changes you make to the document programmatically as revision changes. | ||
void | stopTrackRevisions() | |
Stops automatic marking of document changes as revisions. | ||
java.lang.String | toString(int saveFormat) | → inherited from Node |
Exports the content of the node into a string in the specified format. | ||
java.lang.String | toTxt() | → inherited from Node |
Exports the content of the node into a string in plain text format. | ||
void | unlinkFields() | |
Unlinks fields in the whole document. | ||
void | unprotect() | |
Removes protection from the document regardless of the password. | ||
boolean | unprotect(java.lang.String password) | |
Removes protection from the document if a correct password is specified. | ||
void | updateFields() | |
Updates the values of fields in the whole document. | ||
void | updateListLabels() | |
Updates list labels for all list items in the document. | ||
void | updatePageLayout() | |
Rebuilds the page layout of the document. | ||
void | 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. | ||
void | updateThumbnail() | |
Updates |
||
void | updateWordCount() | |
Updates word count properties of the document. | ||
void | updateWordCount(boolean updateLinesCount) | |
Updates word count properties of the document, optionally updates |
Constructor Detail |
---|
public Document() throws java.lang.Exception
The document paper size is Letter by default. If you want to change page setup, use
After creation, you can use
public Document(java.lang.String fileName) throws java.lang.Exception
fileName
- File name of the document to open.public Document(java.lang.String fileName, LoadOptions loadOptions) throws java.lang.Exception
fileName
- File name of the document to open.loadOptions
- Additional options to use when loading a document. Can be null.public Document(java.io.InputStream stream) throws java.lang.Exception
The document must be stored at the beginning of the stream.
stream
- Stream where to load the document from.public Document(java.io.InputStream stream, LoadOptions loadOptions) throws java.lang.Exception
The document must be stored at the beginning of the stream.
stream
- The stream where to load the document from.loadOptions
- Additional options to use when loading a document. Can be null.Property Getters/Setters Detail |
---|
getAttachedTemplate/setAttachedTemplate | |
public java.lang.String getAttachedTemplate() / public void setAttachedTemplate(java.lang.String value) |
Empty string means the document is attached to the Normal template.
getAutomaticallyUpdateSyles/setAutomaticallyUpdateSyles | |
public boolean getAutomaticallyUpdateSyles() / public void setAutomaticallyUpdateSyles(boolean value) |
getBackgroundShape/setBackgroundShape | → inherited from DocumentBase |
public Shape getBackgroundShape() / public void setBackgroundShape(Shape value) |
Microsoft Word allows only a shape that has its
Microsoft Word supports only the fill properties of a background shape. All other properties are ignored.
Setting this property to a non-null value will also set the
getBuiltInDocumentProperties | |
public Aspose.Words.Properties.BuiltInDocumentProperties getBuiltInDocumentProperties() |
getChildNodes | → inherited from CompositeNode |
public NodeCollection getChildNodes() |
Note, GetChildNodes(NodeType.Any, false)
and creates and returns a new collection every time it is accessed.
If there are no child nodes, this property returns an empty collection.
getCompatibilityOptions | |
public Aspose.Words.Settings.CompatibilityOptions getCompatibilityOptions() |
getCompliance | |
public Aspose.Words.Saving.OoxmlCompliance getCompliance() |
If you created a new blank document or load non OOXML document
returns the
getCount | → inherited from CompositeNode |
public int getCount() |
getCustomDocumentProperties | |
public Aspose.Words.Properties.CustomDocumentProperties getCustomDocumentProperties() |
getCustomXmlParts | |
public Aspose.Words.Markup.CustomXmlPartCollection getCustomXmlParts() |
Aspose.Words loads and saves Custom XML Parts into OOXML and DOC documents only.
This property cannot be null
.
getDefaultTabStop/setDefaultTabStop | |
public double getDefaultTabStop() / public void setDefaultTabStop(double value) |
getDigitalSignatures | |
public DigitalSignatureCollection getDigitalSignatures() |
This collection contains digital signatures that were loaded from the original document.
These digital signatures will not be saved when you save this
This collection is never null. If the document is not signed, it will contain zero elements.
getDocument | → inherited from Node |
public DocumentBase getDocument() |
The node always belongs to a document even if it has just been created and not yet added to the tree, or if it has been removed from the tree.
getEndnoteOptions | |
public EndnoteOptions getEndnoteOptions() |
getFieldOptions | |
public Aspose.Words.Fields.FieldOptions getFieldOptions() |
getFirstChild | → inherited from CompositeNode |
public Node getFirstChild() |
getFirstSection | |
public Section getFirstSection() |
null
if there are no sections.
getFontInfos | → inherited from DocumentBase |
public Aspose.Words.Fonts.FontInfoCollection getFontInfos() |
This collection of font definitions is loaded as is from the document. Font definitions might be optional, missing or incomplete in some documents.
Do not rely on this collection to ascertain that a particular font is used in the document. You should only use this collection to get information about fonts that might be used in the document.
getFontSettings | |
public Aspose.Words.Fonts.FontSettings getFontSettings() |
This property allows to specify font settings per document. If set to null, default static font settings
The default value is null.
getFootnoteOptions | |
public FootnoteOptions getFootnoteOptions() |
getGlossaryDocument/setGlossaryDocument | |
public GlossaryDocument getGlossaryDocument() / public void setGlossaryDocument(GlossaryDocument value) |
This property returns null
if the document does not have a glossary document.
You can add a glossary document to a document by creating a
hasChildNodes | → inherited from CompositeNode |
public boolean hasChildNodes() |
hasMacros | |
public boolean hasMacros() |
hasRevisions | |
public boolean hasRevisions() |
getHyphenationOptions | |
public Aspose.Words.Settings.HyphenationOptions getHyphenationOptions() |
isComposite | → inherited from CompositeNode |
public boolean isComposite() |
getLastChild | → inherited from CompositeNode |
public Node getLastChild() |
getLastSection | |
public Section getLastSection() |
null
if there are no sections.
getLayoutOptions | |
public Aspose.Words.Layout.LayoutOptions getLayoutOptions() |
getLists | → inherited from DocumentBase |
public Aspose.Words.Lists.ListCollection getLists() |
For more information see the description of the
getMailMerge | |
public Aspose.Words.MailMerging.MailMerge getMailMerge() |
getMailMergeSettings | |
public Aspose.Words.Settings.MailMergeSettings getMailMergeSettings() |
You can use this object to specify a mail merge data source for a document and this information (along with the available data fields) will appear in Microsoft Word when the user opens this document. Or you can use this object to query mail merge settings that the user has specified in Microsoft Word for this document.
This object is never null.
getNextSibling | → inherited from Node |
public Node getNextSibling() |
getNodeChangingCallback/setNodeChangingCallback | → inherited from DocumentBase |
public INodeChangingCallback getNodeChangingCallback() / public void setNodeChangingCallback(INodeChangingCallback value) |
getNodeType | |
public int getNodeType() |
getOriginalFileName | |
public java.lang.String getOriginalFileName() |
Returns null if the document was loaded from a stream or created blank.
getOriginalLoadFormat | |
public int getOriginalLoadFormat() |
If you created a new blank document, returns the
getPackageCustomParts | |
public Aspose.Words.Markup.CustomPartCollection getPackageCustomParts() |
Do not confuse these custom parts with Custom XML Data. If you need to access Custom XML parts,
use the
This collection contains OOXML parts whose parent is the OOXML package and they targets are of an "unknown relationship".
For more information see
Aspose.Words loads and saves custom parts into OOXML documents only.
This property cannot be null
.
getPageColor | → inherited from DocumentBase |
public java.awt.Color getPageColor() |
This property provides a simple way to specify a solid page color for the document.
Setting this property creates and sets an appropriate
If the page color is not set (e.g. there is no background shape in the document) returns a zero color.
getPageCount | |
public int getPageCount() |
getParentNode | → inherited from Node |
public CompositeNode getParentNode() |
If a node has just been created and not yet added to the tree, or if it has been removed from the tree, the parent is null.
getPreviousSibling | → inherited from Node |
public Node getPreviousSibling() |
getProtectionType | |
public int getProtectionType() |
This property allows to retrieve the currently set document protection type.
To change the document protection type use the
When a document is protected, the user can make only limited changes, such as adding annotations, making revisions, or completing a form.
Note that document protection is different from write protection.
Write protection is specified using the
getRange | → inherited from Node |
public Range getRange() |
getResourceLoadingCallback | → inherited from DocumentBase |
public Aspose.Words.Loading.IResourceLoadingCallback getResourceLoadingCallback() |
getRevisions | |
public RevisionCollection getRevisions() |
The returned collection is a "live" collection, which means if you remove parts of a document that contain revisions, the deleted revisions will automatically disappear from this collection.
getSections | |
public SectionCollection getSections() |
getShadeFormData/setShadeFormData | |
public boolean getShadeFormData() / public void setShadeFormData(boolean value) |
getStyles | → inherited from DocumentBase |
public StyleCollection getStyles() |
For more information see the description of the
getTheme | |
public Aspose.Words.Themes.Theme getTheme() |
getTrackRevisions/setTrackRevisions | |
public boolean getTrackRevisions() / public void setTrackRevisions(boolean value) |
Setting this option only instructs Microsoft Word whether the track changes is turned on or off. This property has no effect on changes to the document that you make programmatically via Aspose.Words.
If you want to automatically track changes as they are made programmatically by Aspose.Words
to this document use the
getVariables | |
public VariableCollection getVariables() |
getVersionsCount | |
public int getVersionsCount() |
Versions in Microsoft Word are accessed via the File/Versions menu. Microsoft Word supports versions only for DOC files.
This property allows to detect if there were document versions stored in this document before it was opened in Aspose.Words. Aspose.Words provides no other support for document versions. If you save this document using Aspose.Words, the document will be saved without versions.
getViewOptions | |
public Aspose.Words.Settings.ViewOptions getViewOptions() |
getWarningCallback/setWarningCallback | → inherited from DocumentBase |
public IWarningCallback getWarningCallback() / public void setWarningCallback(IWarningCallback value) |
getWriteProtection | |
public Aspose.Words.Settings.WriteProtection getWriteProtection() |
Method Detail |
---|
accept | |
public boolean accept(DocumentVisitor visitor) throws java.lang.Exception |
Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.
For more info see the Visitor design pattern.
visitor
- The visitor that will visit the nodes.acceptAllRevisions | |
public void acceptAllRevisions() throws java.lang.Exception |
appendChild | → inherited from CompositeNode |
public Node appendChild(Node newChild) |
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use
newChild
- The node to add.appendDocument | |
public void appendDocument(Document srcDoc, int importFormatMode) |
srcDoc
- The document to append.importFormatMode
- A cleanup | |
public void cleanup() throws java.lang.Exception |
cleanup | |
public void cleanup(CleanupOptions options) throws java.lang.Exception |
clearSectionAttrs | |
public void clearSectionAttrs() |
compare | |
public void compare(Document document, java.lang.String author, java.util.Date dateTime) throws java.lang.Exception |
Note: Documents must not have revisions before comparison.
document
- Document to compare.author
- Initials of the author to use for revisions.dateTime
- The date and time to use for revisions.compare | |
public void compare(Document document, java.lang.String author, java.util.Date dateTime, CompareOptions options) throws java.lang.Exception |
deepClone | |
public Document deepClone() |
deepClone | → inherited from Node |
public Node deepClone(boolean isCloneChildren) |
This method serves as a copy constructor for nodes. The cloned node has no parent, but belongs to the same document as the original node.
This method always performs a deep copy of the node. The isCloneChildren parameter specifies whether to perform copy all child nodes as well.
isCloneChildren
- True to recursively clone the subtree under the specified node;
false to clone only the node itself.ensureMinimum | |
public void ensureMinimum() |
expandTableStylesToDirectFormatting | |
public void expandTableStylesToDirectFormatting() throws java.lang.Exception |
This method exists because this version of Aspose.Words provides only limited support for table styles (see below). This method might be useful when you load a DOCX or WordprocessingML document that contains tables formatted with table styles and you need to query formatting of tables, cells, paragraphs or text.
This version of Aspose.Words provides limited support for table styles as follows:
fetchInheritedSectionAttr | |
public java.lang.Object fetchInheritedSectionAttr(int key) |
getAncestor | → inherited from Node |
public CompositeNode getAncestor(int ancestorType) |
ancestorType
- A getAncestor | → inherited from Node |
public CompositeNode getAncestor(java.lang.Class ancestorType) |
The ancestor type matches if it is equal to ancestorType or derived from ancestorType.
ancestorType
- The object type of the ancestor to retrieve.getChild | → inherited from CompositeNode |
public Node getChild(int nodeType, int index, boolean isDeep) |
If index is out of range, a null is returned.
nodeType
- A index
- Zero based index of the child node to select.
Negative indexes are also allowed and indicate access from the end,
that is -1 means the last node.isDeep
- True to select from all child nodes recursively.
False to select only among immediate children. See remarks for more info.getChildNodes | → inherited from CompositeNode |
public NodeCollection getChildNodes(int nodeType, boolean isDeep) |
The collection of nodes returned by this method is always live.
A live collection is always in sync with the document. For example, if you selected all sections in a document and enumerate through the collection deleting the sections, the section is removed from the collection immediately when it is removed from the document.
nodeType
- A isDeep
- True to select from all child nodes recursively.
False to select only among immediate children. getContainer | → inherited from CompositeNode |
public CompositeNode getContainer() |
getDirectSectionAttr | |
public java.lang.Object getDirectSectionAttr(int key) |
getNextMatchingNode | → inherited from CompositeNode |
public Node getNextMatchingNode(aspose.obfuscated.type curNode) |
getPageInfo | |
public Aspose.Words.Rendering.PageInfo getPageInfo(int pageIndex) throws java.lang.Exception |
pageIndex
- The 0-based page index.getText | → inherited from CompositeNode |
public java.lang.String getText() |
The returned string includes all control and special characters as described in
importNode | → inherited from DocumentBase |
public Node importNode(Node srcNode, boolean isImportChildren) |
Imports a node from another document to the current document.
This method uses the
Importing a node creates a copy of the source node belonging to the importing document. The returned node has no parent. The source node is not altered or removed from the original document.
Before a node from another document can be inserted into this document, it must be imported.
During import, document-specific properties such as references to styles and lists are translated
from the original to the importing document. After the node was imported, it can be inserted
into the appropriate place in the document using
If the source node already belongs to the destination document, then simply a deep clone of the source node is created.
srcNode
- The node being imported.isImportChildren
- True to import all child nodes recursively; otherwise, false.importNode | → inherited from DocumentBase |
public Node importNode(Node srcNode, boolean isImportChildren, int importFormatMode) |
Imports a node from another document to the current document with an option to control formatting.
This overload is useful to control how styles and list formatting are imported.
Importing a node creates a copy of the source node belonging to the importing document. The returned node has no parent. The source node is not altered or removed from the original document.
Before a node from another document can be inserted into this document, it must be imported.
During import, document-specific properties such as references to styles and lists are translated
from the original to the importing document. After the node was imported, it can be inserted
into the appropriate place in the document using
If the source node already belongs to the destination document, then simply a deep clone of the source node is created.
srcNode
- The node to imported.isImportChildren
- True to import all child nodes recursively; otherwise, false.importFormatMode
- A indexOf | → inherited from CompositeNode |
public int indexOf(Node child) |
insertAfter | → inherited from CompositeNode |
public Node insertAfter(Node newChild, Node refChild) |
If refChild is null, inserts newChild at the beginning of the list of child nodes.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use
newChild
- The Node to insert.refChild
- The Node that is the reference node. The newNode is placed after the refNode. insertBefore | → inherited from CompositeNode |
public Node insertBefore(Node newChild, Node refChild) |
If refChild is null, inserts newChild at the end of the list of child nodes.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use
newChild
- The Node to insert.refChild
- The Node that is the reference node. The newChild is placed before this node.invalidateFieldTypes | |
public void invalidateFieldTypes() |
Use this method after document changes that affect field types.
To change field type values in a specific part of the document use
iterator | → inherited from CompositeNode |
public java.util.Iterator iterator() |
joinRunsWithSameFormatting | |
public int joinRunsWithSameFormatting() |
This is an optimization method. Some documents contain adjacent runs with same formatting. Usually this occurs if a document was intensively edited manually. You can reduce the document size and speed up further processing by joining these runs.
The operation checks every
nextPreOrder | → inherited from Node |
public Node nextPreOrder(Node rootNode) |
rootNode
- The top node (limit) of traversal.normalizeFieldTypes | |
public void normalizeFieldTypes() |
Use this method after document changes that affect field types.
To change field type values in a specific part of the document use
prependChild | → inherited from CompositeNode |
public Node prependChild(Node newChild) |
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use
newChild
- The node to add.previousPreOrder | → inherited from Node |
public Node previousPreOrder(Node rootNode) |
rootNode
- The top node (limit) of traversal.protect | |
public void protect(int type) |
When a document is protected, the user can make only limited changes, such as adding annotations, making revisions, or completing a form.
When you protect a document, and the document already has a protection password, the existing protection password is not changed.
When you protect a document, and the document does not have a protection password, this method assigns a random password that makes it impossible to unprotect the document in Microsoft Word, but you still can unprotect the document in Aspose.Words as it does not require a password when unprotecting.
type
- A protect | |
public void protect(int type, java.lang.String password) |
When a document is protected, the user can make only limited changes, such as adding annotations, making revisions, or completing a form.
Note that document protection is different from write protection.
Write protection is specified using the
type
- A password
- The password to protect the document with.
Specify null or empty string if you want to protect the document without a password.remove | → inherited from Node |
public void remove() |
removeAllChildren | → inherited from CompositeNode |
public void removeAllChildren() |
removeChild | → inherited from CompositeNode |
public Node removeChild(Node oldChild) |
The parent of oldChild is set to null after the node is removed.
oldChild
- The node to remove.removeExternalSchemaReferences | |
public void removeExternalSchemaReferences() |
removeMacros | |
public void removeMacros() |
By removing all macros from a document you can ensure the document contains no macro viruses.
removeSmartTags | → inherited from CompositeNode |
public void removeSmartTags() |
removeUnusedResources | |
public void removeUnusedResources() throws java.lang.Exception |
save | |
public void save(java.io.OutputStream outputStream, com.aspose.words.SaveOptions saveOptions) throws java.lang.Exception |
stream
- Stream where to save the document.saveOptions
- Specifies the options that control how the document is saved. Can be null.
If this is null, the document will be saved in the binary DOC format.save | |
public void save(java.io.OutputStream outputStream, int saveFormat) throws java.lang.Exception |
stream
- Stream where to save the document.saveFormat
- The format in which to save the document.save | |
public Aspose.Words.Saving.SaveOutputParameters save(java.lang.String fileName) throws java.lang.Exception |
fileName
- The name for the document. If a document with the
specified file name already exists, the existing document is overwritten.save | |
public Aspose.Words.Saving.SaveOutputParameters save(java.lang.String fileName, int saveFormat) throws java.lang.Exception |
fileName
- The name for the document. If a document with the
specified file name already exists, the existing document is overwritten.saveFormat
- A selectNodes | → inherited from CompositeNode |
public NodeList selectNodes(java.lang.String xpath) |
Only expressions with element names are supported at the moment. Expressions that use attribute names are not supported.
xpath
- The XPath expression.selectSingleNode | → inherited from CompositeNode |
public Node selectSingleNode(java.lang.String xpath) |
Only expressions with element names are supported at the moment. Expressions that use attribute names are not supported.
xpath
- The XPath expression.setSectionAttr | |
public void setSectionAttr(int key, java.lang.Object value) |
startTrackRevisions | |
public void startTrackRevisions(java.lang.String author) |
If you call this method and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.
Currently Aspose.Words supports tracking of node insertions and deletions only. Formatting changes are not recorded as revisions.
Automatic tracking of changes is supported both when modifying this document through node manipulations
as well as when using
This method does not change the
author
- Initials of the author to use for revisions.startTrackRevisions | |
public void startTrackRevisions(java.lang.String author, java.util.Date dateTime) |
If you call this method and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.
Currently Aspose.Words supports tracking of node insertions and deletions only. Formatting changes are not recorded as revisions.
Automatic tracking of changes is supported both when modifying this document through node manipulations
as well as when using
This method does not change the
author
- Initials of the author to use for revisions.dateTime
- The date and time to use for revisions.stopTrackRevisions | |
public void stopTrackRevisions() |
toString | → inherited from Node |
public java.lang.String toString(int saveFormat) throws java.lang.Exception |
saveFormat
- A SaveFormat value.toTxt | → inherited from Node |
public java.lang.String toTxt() throws java.lang.Exception |
This method removes field codes and Microsoft Word control characters, uses CrLf
(or any other) combination of characters to mark ends of paragraphs in the resulting string.
It produces a different result from
unlinkFields | |
public void unlinkFields() throws java.lang.Exception |
Replaces all the fields in the whole document with their most recent results.
To unlink fields in a specific part of the document use
unprotect | |
public void unprotect() |
This method unprotects the document even if it has a protection password.
Note that document protection is different from write protection.
Write protection is specified using the
unprotect | |
public boolean unprotect(java.lang.String password) |
This method unprotects the document only if a correct password is specified.
Note that document protection is different from write protection.
Write protection is specified using the
password
- The password to unprotect the document with.updateFields | |
public void updateFields() throws java.lang.Exception |
When you open, modify and then save a document, Aspose.Words does not update fields automatically, it keeps them intact. Therefore, you would usually want to call this method before saving if you have modified the document programmatically and want to make sure the proper (calculated) field values appear in the saved document.
There is no need to update fields after executing a mail merge because mail merge is a kind of field update and automatically updates all fields in the document.
This method does not update all field types. For the detailed list of supported field types, see the Programmers Guide.
This method does not update fields that are related to the page layout algorithms (e.g. PAGE, PAGES, PAGEREF).
The page layout-related fields are updated when you render a document or call
Use the
To update fields in a specific part of the document use
updateListLabels | |
public void updateListLabels() throws java.lang.Exception |
This method updates list label properties such as
Also, this method is sometimes implicitly called when updating fields in the document. This is required because some fields that may reference list numbers (such as TOC or REF) need them be up-to-date.
updatePageLayout | |
public void updatePageLayout() throws java.lang.Exception |
This method formats a document into pages and updates the page number related fields in the document such as PAGE, PAGES, PAGEREF and REF. The up-to-date page layout information is required for a correct rendering of the document to fixed-page formats.
This method is automatically invoked when you first convert a document to PDF, XPS, image or print it.
However, if you modify the document after rendering and then attempt to render it again - Aspose.Words will not
update the page layout automatically. In this case you should call
updateTableLayout | |
public void updateTableLayout() |
You do not normally need to call this method as cell and table widths are maintained automatically. You can call this method before exporting to PDF (or any other fixed-page format), only in rare cases where you confirmed that tables appear incorrectly laid out in the output document. Calling this method might help to correct the output.
updateThumbnail | |
public void updateThumbnail() throws java.lang.Exception |
updateWordCount | |
public void updateWordCount() throws java.lang.Exception |
UpdateWordCount recalculates and updates Characters, Words and Paragraphs
properties in the
Note that UpdateWordCount does not update number of lines and pages properties.
Use the
When you use an evaluation version, the evaluation watermark will also be included in the word count.
updateWordCount | |
public void updateWordCount(boolean updateLinesCount) throws java.lang.Exception |
updateLinesCount
- True if number of lines in the document shall be calculated.