Document
Overview
Document is a class in Aspose.Words FOSS for Java.
Inherits from: DocumentBase<Node>, ISectionAttrSource, IWatermarkProvider.
Represents a Word document.
Edition status of its 139 listed members (a property and its accessor methods are listed separately, overloads once): 2 limited, 128 not yet exercised by a verified example.
This class declares 107 methods for Document objects in Java programs.
Available methods include: Document, accept, acceptAllRevisions, acceptEnd, acceptStart, appendDocument, cleanup, copyStylesFromTemplate, deepClone, ensureMinimum, expandTableStylesToDirectFormatting, getAttachedTemplate, and 81 additional methods.
Public members are accessible to any Java application after installing the Aspose.Words FOSS for Java package.
Properties: attachedTemplate, automaticallyUpdateStyles, bibliography, builtInDocumentProperties, compatibilityOptions, compliance, and 40 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
attachedTemplate | String | Read/Write | Gets or sets the full path of the template attached to the document. |
automaticallyUpdateStyles | boolean | Read/Write | 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. |
shadeFormData | boolean | Read/Write | Specifies whether to turn on the gray shading on form fields. |
trackRevisions | boolean | Read/Write | True if changes are tracked when this document is edited in Microsoft Word. |
showGrammaticalErrors | boolean | Read/Write | Specifies whether to display grammar errors in this document. |
showSpellingErrors | boolean | Read/Write | Specifies whether to display spelling errors in this document. |
spellingChecked | boolean | Read/Write | Returns true if the document has been checked for spelling. |
grammarChecked | boolean | Read/Write | Returns true if the document has been checked for grammar. |
punctuationKerning | boolean | Read/Write | Specifies whether kerning applies to both Latin text and punctuation. |
nodeType | int | Read | Returns Document. |
builtInDocumentProperties | BuiltInDocumentProperties | Read | Returns a collection that represents all the built-in document properties of the document. |
webExtensionTaskPanes | TaskPaneCollection | Read | Returns a collection that represents a list of task pane add-ins. |
customDocumentProperties | CustomDocumentProperties | Read | Returns a collection that represents all the custom document properties of the document. |
protectionType | int | Read | Gets the currently active document protection type. |
sections | SectionCollection | Read | Returns a collection that represents all sections in the document. |
firstSection | Section | Read | Gets the first section in the document. |
lastSection | Section | Read | Gets the last section in the document. |
viewOptions | ViewOptions | Read | Provides options to control how the document is displayed in Microsoft Word. |
writeProtection | WriteProtection | Read | Provides access to the document write protection options. |
compatibilityOptions | CompatibilityOptions | Read | Provides access to document compatibility options (that is, the user preferences entered on the Compatibility tab of the Options dialog in Word). |
mailMergeSettings | MailMergeSettings | Read/Write | Gets or sets the object that contains all of the mail merge information for a document. |
hyphenationOptions | HyphenationOptions | Read | Provides access to document hyphenation options. |
watermark | Watermark | Read | Provides access to the document watermark. |
versionsCount | int | Read | Gets the number of document versions that was stored in the DOC document. |
defaultTabStop | double | Read/Write | Gets or sets the interval (in points) between the default tab stops. |
theme | Theme | Read | Gets the Theme object for this document. |
customXmlParts | CustomXmlPartCollection | Read/Write | Gets or sets the collection of Custom XML Data Storage Parts. |
packageCustomParts | CustomPartCollection | Read/Write | Gets or sets the collection of custom parts (arbitrary content) that are linked to the OOXML package using “unknown relationships”. |
variables | VariableCollection | Read | Returns the collection of variables added to a document or template. |
glossaryDocument | GlossaryDocument | Read/Write | Gets or sets the glossary document within this document or template. |
originalFileName | String | Read | Gets the original file name of the document. |
originalLoadFormat | int | Read | Gets the format of the original document that was loaded into this object. |
compliance | int | Read | Gets the OOXML compliance version determined from the loaded document content. |
digitalSignatures | DigitalSignatureCollection | Read | Gets the collection of digital signatures for this document and their validation results. |
fontSettings | FontSettings | Read/Write | Gets or sets document font settings. |
bibliography | Bibliography | Read | Gets the Bibliography object that represents the list of sources available in the document. |
frameset | Frameset | Read | Returns a Frameset instance if this document represents a frames page. |
includeTextboxesFootnotesEndnotesInStat | boolean | Read/Write | Specifies whether to include textboxes, footnotes and endnotes in word count statistics. |
revisions | RevisionCollection | Read | Gets a collection of revisions (tracked changes) that exist in this document. |
revisionsView | int | Read/Write | Gets or sets a value indicating whether to work with the original or revised version of a document. |
justificationMode | int | Read/Write | Gets or sets the character spacing adjustment of a document. |
footnoteOptions | FootnoteOptions | Read | Provides options that control numbering and positioning of footnotes in this document. |
endnoteOptions | EndnoteOptions | Read | Provides options that control numbering and positioning of endnotes in this document. |
fieldOptions | FieldOptions | Read | Gets a FieldOptions object that represents options to control field handling in the document. |
removePersonalInformation | boolean | Read/Write | Gets or sets a flag indicating that Microsoft Word will remove all user information from comments, revisions and document properties upon saving the document. |
vbaProject | VbaProject | Read/Write | Gets or sets a VbaProject. |
Methods
| Signature | Description |
|---|---|
Document() | Limited in the FOSS edition — some inputs are rejected. Creates a blank Word document. |
Document(fileName: String) | Limited in the FOSS edition — some inputs are rejected. Opens an existing document from a file. |
Document(fileName: String, loadOptions: LoadOptions) | Limited in the FOSS edition — some inputs are rejected. Opens an existing document from a file. |
Document(stream: java.io.InputStream) | Limited in the FOSS edition — some inputs are rejected. Creates a new Document instance from stream. |
Document(stream: java.io.InputStream, loadOptions: LoadOptions) | Limited in the FOSS edition — some inputs are rejected. Creates a new Document instance from stream, loadOptions. |
getAttachedTemplate() → String | Gets or sets the full path of the template attached to the document. |
setAttachedTemplate(value: String) | Sets the attached template value. |
getAutomaticallyUpdateStyles() → boolean | 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. |
setAutomaticallyUpdateStyles(value: boolean) | Sets the automatically update styles value. |
getShadeFormData() → boolean | Specifies whether to turn on the gray shading on form fields. |
setShadeFormData(value: boolean) | Sets the shade form data value. |
getTrackRevisions() → boolean | True if changes are tracked when this document is edited in Microsoft Word. |
setTrackRevisions(value: boolean) | Sets the track revisions value. |
getShowGrammaticalErrors() → boolean | Specifies whether to display grammar errors in this document. |
setShowGrammaticalErrors(value: boolean) | Sets the show grammatical errors value. |
getShowSpellingErrors() → boolean | Specifies whether to display spelling errors in this document. |
setShowSpellingErrors(value: boolean) | Sets the show spelling errors value. |
getSpellingChecked() → boolean | Returns true if the document has been checked for spelling. |
setSpellingChecked(value: boolean) | Sets the spelling checked value. |
getGrammarChecked() → boolean | Returns true if the document has been checked for grammar. |
setGrammarChecked(value: boolean) | Sets the grammar checked value. |
getPunctuationKerning() → boolean | Specifies whether kerning applies to both Latin text and punctuation. |
setPunctuationKerning(value: boolean) | Sets the punctuation kerning value. |
getNodeType() → int | Returns Document. |
getBuiltInDocumentProperties() → BuiltInDocumentProperties | Returns a collection that represents all the built-in document properties of the document. |
getWebExtensionTaskPanes() → TaskPaneCollection | Returns a collection that represents a list of task pane add-ins. |
getCustomDocumentProperties() → CustomDocumentProperties | Returns a collection that represents all the custom document properties of the document. |
getProtectionType() → int | Gets the currently active document protection type. |
getSections() → SectionCollection | Returns a collection that represents all sections in the document. |
getFirstSection() → Section | Gets the first section in the document. |
getLastSection() → Section | Gets the last section in the document. |
getViewOptions() → ViewOptions | Provides options to control how the document is displayed in Microsoft Word. |
getWriteProtection() → WriteProtection | Provides access to the document write protection options. |
getCompatibilityOptions() → CompatibilityOptions | Provides access to document compatibility options (that is, the user preferences entered on the Compatibility tab of the Options dialog in Word). |
getMailMergeSettings() → MailMergeSettings | Gets or sets the object that contains all of the mail merge information for a document. |
setMailMergeSettings(value: MailMergeSettings) | Sets the mail merge settings value. |
getHyphenationOptions() → HyphenationOptions | Provides access to document hyphenation options. |
hasRevisions() → boolean | Returns true if the document has any tracked changes. |
hasMacros() → boolean | Returns true if the document has a VBA project (macros). |
getWatermark() → Watermark | Provides access to the document watermark. |
getVersionsCount() → int | Gets the number of document versions that was stored in the DOC document. |
getDefaultTabStop() → double | Gets or sets the interval (in points) between the default tab stops. |
setDefaultTabStop(value: double) | Sets the default tab stop value. |
getTheme() → Theme | Gets the Theme object for this document. |
getCustomXmlParts() → CustomXmlPartCollection | Gets or sets the collection of Custom XML Data Storage Parts. |
setCustomXmlParts(value: CustomXmlPartCollection) | Sets the custom xml parts value. |
getPackageCustomParts() → CustomPartCollection | Gets or sets the collection of custom parts (arbitrary content) that are linked to the OOXML package using “unknown relationships”. |
setPackageCustomParts(value: CustomPartCollection) | Sets the package custom parts value. |
getVariables() → VariableCollection | Returns the collection of variables added to a document or template. |
getGlossaryDocument() → GlossaryDocument | Gets or sets the glossary document within this document or template. |
setGlossaryDocument(value: GlossaryDocument) | Sets the glossary document value. |
getOriginalFileName() → String | Gets the original file name of the document. |
getOriginalLoadFormat() → int | Gets the format of the original document that was loaded into this object. |
getCompliance() → int | Gets the OOXML compliance version determined from the loaded document content. |
getDigitalSignatures() → DigitalSignatureCollection | Gets the collection of digital signatures for this document and their validation results. |
getFontSettings() → FontSettings | Gets or sets document font settings. |
setFontSettings(value: FontSettings) | Sets the font settings value. |
getBibliography() → Bibliography | Gets the Bibliography object that represents the list of sources available in the document. |
getFrameset() → Frameset | Returns a Frameset instance if this document represents a frames page. |
getIncludeTextboxesFootnotesEndnotesInStat() → boolean | Specifies whether to include textboxes, footnotes and endnotes in word count statistics. |
setIncludeTextboxesFootnotesEndnotesInStat(value: boolean) | Sets the include textboxes footnotes endnotes in stat value. |
deepClone() → Document | Performs a deep copy of the Document. |
accept(visitor: DocumentVisitor) → boolean | Calls accept(visitor) on this Document instance. |
acceptStart(visitor: DocumentVisitor) → int | Accepts a visitor for visiting the start of the document. |
acceptEnd(visitor: DocumentVisitor) → int | Accepts a visitor for visiting the end of the document. |
appendDocument(srcDoc: Document, importFormatMode: int) | Appends the specified document to the end of this document. |
appendDocument(srcDoc: Document, importFormatMode: int, importFormatOptions: ImportFormatOptions) | Appends the specified document to the end of this document. |
save(fileName: String) → SaveOutputParameters | Limited in the FOSS edition — some inputs are rejected. Saves the document to a file. |
save(fileName: String, saveFormat: int) → SaveOutputParameters | Limited in the FOSS edition — some inputs are rejected. Saves the document to a file in the specified format. |
save(fileName: String, saveOptions: SaveOptions) → SaveOutputParameters | Limited in the FOSS edition — some inputs are rejected. Saves the document to a file using the specified save options. |
save(stream: java.io.OutputStream, saveFormat: int) → SaveOutputParameters | Limited in the FOSS edition — some inputs are rejected. Calls save(stream, saveFormat) on this Document instance. |
save(stream: java.io.OutputStream, saveOptions: SaveOptions) → SaveOutputParameters | Limited in the FOSS edition — some inputs are rejected. Calls save(stream, saveOptions) on this Document instance. |
ensureMinimum() | If the document contains no sections, creates one section with one paragraph. |
acceptAllRevisions() | Accepts all tracked changes in the document. |
protect(type: int) | Protects the document from changes without changing the existing password or assigns a random password. |
protect(type: int, password: String) | Protects the document from changes and optionally sets a protection password. |
unprotect() | Removes protection from the document regardless of the password. |
unprotect(password: String) → boolean | Removes protection from the document if a correct password is specified. |
updateTableLayout() | Implements an earlier approach to table column widths re-calculation that has known issues. |
updateListLabels() | Updates list labels for all list items in the document. |
updateActualReferenceMarks() | Updates the Footnote.getActualReferenceMark() property of all footnotes and endnotes in the document. |
removeMacros() | Removes all macros (the VBA project) as well as toolbars and command customizations from the document. |
updateFields() | Updates the values of fields in the whole document. |
unlinkFields() | Unlinks fields in the whole document. |
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. |
joinRunsWithSameFormatting() → int | Joins runs with same formatting in all paragraphs of the document. |
expandTableStylesToDirectFormatting() | Converts formatting specified in table styles into direct formatting on tables in the document. |
cleanup() | Cleans unused styles and lists from the document. |
cleanup(options: CleanupOptions) | Cleans unused styles and lists from the document depending on given CleanupOptions. |
removeExternalSchemaReferences() | Removes external XML schema references from this document. |
startTrackRevisions(author: String, dateTime: java.util.Date) | Calls startTrackRevisions(author, dateTime) on this Document instance. |
startTrackRevisions(author: String) | Starts automatically marking all further changes you make to the document programmatically as revision changes. |
stopTrackRevisions() | Stops automatic marking of document changes as revisions. |
copyStylesFromTemplate(template: String) | Copies styles from the specified template to a document. |
copyStylesFromTemplate(template: Document) | Copies styles from the specified template to a document. |
getRevisions() → RevisionCollection | Gets a collection of revisions (tracked changes) that exist in this document. |
getRevisionsView() → int | Gets or sets a value indicating whether to work with the original or revised version of a document. |
setRevisionsView(value: int) | Sets the revisions view value. |
getJustificationMode() → int | Gets or sets the character spacing adjustment of a document. |
setJustificationMode(value: int) | Sets the justification mode value. |
getFootnoteOptions() → FootnoteOptions | Provides options that control numbering and positioning of footnotes in this document. |
getEndnoteOptions() → EndnoteOptions | Provides options that control numbering and positioning of endnotes in this document. |
getFieldOptions() → FieldOptions | Gets a FieldOptions object that represents options to control field handling in the document. |
getRemovePersonalInformation() → boolean | Gets or sets a flag indicating that Microsoft Word will remove all user information from comments, revisions and document properties upon saving the document. |
setRemovePersonalInformation(value: boolean) | Sets the remove personal information value. |
getVbaProject() → VbaProject | Gets or sets a VbaProject. |
setVbaProject(value: VbaProject) | Sets the vba project value. |