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

NameTypeAccessDescription
attachedTemplateStringRead/WriteGets or sets the full path of the template attached to the document.
automaticallyUpdateStylesbooleanRead/WriteGets 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.
shadeFormDatabooleanRead/WriteSpecifies whether to turn on the gray shading on form fields.
trackRevisionsbooleanRead/WriteTrue if changes are tracked when this document is edited in Microsoft Word.
showGrammaticalErrorsbooleanRead/WriteSpecifies whether to display grammar errors in this document.
showSpellingErrorsbooleanRead/WriteSpecifies whether to display spelling errors in this document.
spellingCheckedbooleanRead/WriteReturns true if the document has been checked for spelling.
grammarCheckedbooleanRead/WriteReturns true if the document has been checked for grammar.
punctuationKerningbooleanRead/WriteSpecifies whether kerning applies to both Latin text and punctuation.
nodeTypeintReadReturns Document.
builtInDocumentPropertiesBuiltInDocumentPropertiesReadReturns a collection that represents all the built-in document properties of the document.
webExtensionTaskPanesTaskPaneCollectionReadReturns a collection that represents a list of task pane add-ins.
customDocumentPropertiesCustomDocumentPropertiesReadReturns a collection that represents all the custom document properties of the document.
protectionTypeintReadGets the currently active document protection type.
sectionsSectionCollectionReadReturns a collection that represents all sections in the document.
firstSectionSectionReadGets the first section in the document.
lastSectionSectionReadGets the last section in the document.
viewOptionsViewOptionsReadProvides options to control how the document is displayed in Microsoft Word.
writeProtectionWriteProtectionReadProvides access to the document write protection options.
compatibilityOptionsCompatibilityOptionsReadProvides access to document compatibility options (that is, the user preferences entered on the Compatibility tab of the Options dialog in Word).
mailMergeSettingsMailMergeSettingsRead/WriteGets or sets the object that contains all of the mail merge information for a document.
hyphenationOptionsHyphenationOptionsReadProvides access to document hyphenation options.
watermarkWatermarkReadProvides access to the document watermark.
versionsCountintReadGets the number of document versions that was stored in the DOC document.
defaultTabStopdoubleRead/WriteGets or sets the interval (in points) between the default tab stops.
themeThemeReadGets the Theme object for this document.
customXmlPartsCustomXmlPartCollectionRead/WriteGets or sets the collection of Custom XML Data Storage Parts.
packageCustomPartsCustomPartCollectionRead/WriteGets or sets the collection of custom parts (arbitrary content) that are linked to the OOXML package using “unknown relationships”.
variablesVariableCollectionReadReturns the collection of variables added to a document or template.
glossaryDocumentGlossaryDocumentRead/WriteGets or sets the glossary document within this document or template.
originalFileNameStringReadGets the original file name of the document.
originalLoadFormatintReadGets the format of the original document that was loaded into this object.
complianceintReadGets the OOXML compliance version determined from the loaded document content.
digitalSignaturesDigitalSignatureCollectionReadGets the collection of digital signatures for this document and their validation results.
fontSettingsFontSettingsRead/WriteGets or sets document font settings.
bibliographyBibliographyReadGets the Bibliography object that represents the list of sources available in the document.
framesetFramesetReadReturns a Frameset instance if this document represents a frames page.
includeTextboxesFootnotesEndnotesInStatbooleanRead/WriteSpecifies whether to include textboxes, footnotes and endnotes in word count statistics.
revisionsRevisionCollectionReadGets a collection of revisions (tracked changes) that exist in this document.
revisionsViewintRead/WriteGets or sets a value indicating whether to work with the original or revised version of a document.
justificationModeintRead/WriteGets or sets the character spacing adjustment of a document.
footnoteOptionsFootnoteOptionsReadProvides options that control numbering and positioning of footnotes in this document.
endnoteOptionsEndnoteOptionsReadProvides options that control numbering and positioning of endnotes in this document.
fieldOptionsFieldOptionsReadGets a FieldOptions object that represents options to control field handling in the document.
removePersonalInformationbooleanRead/WriteGets or sets a flag indicating that Microsoft Word will remove all user information from comments, revisions and document properties upon saving the document.
vbaProjectVbaProjectRead/WriteGets or sets a VbaProject.

Methods

SignatureDescription
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() → StringGets or sets the full path of the template attached to the document.
setAttachedTemplate(value: String)Sets the attached template value.
getAutomaticallyUpdateStyles() → booleanGets 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() → booleanSpecifies whether to turn on the gray shading on form fields.
setShadeFormData(value: boolean)Sets the shade form data value.
getTrackRevisions() → booleanTrue if changes are tracked when this document is edited in Microsoft Word.
setTrackRevisions(value: boolean)Sets the track revisions value.
getShowGrammaticalErrors() → booleanSpecifies whether to display grammar errors in this document.
setShowGrammaticalErrors(value: boolean)Sets the show grammatical errors value.
getShowSpellingErrors() → booleanSpecifies whether to display spelling errors in this document.
setShowSpellingErrors(value: boolean)Sets the show spelling errors value.
getSpellingChecked() → booleanReturns true if the document has been checked for spelling.
setSpellingChecked(value: boolean)Sets the spelling checked value.
getGrammarChecked() → booleanReturns true if the document has been checked for grammar.
setGrammarChecked(value: boolean)Sets the grammar checked value.
getPunctuationKerning() → booleanSpecifies whether kerning applies to both Latin text and punctuation.
setPunctuationKerning(value: boolean)Sets the punctuation kerning value.
getNodeType() → intReturns Document.
getBuiltInDocumentProperties() → BuiltInDocumentPropertiesReturns a collection that represents all the built-in document properties of the document.
getWebExtensionTaskPanes() → TaskPaneCollectionReturns a collection that represents a list of task pane add-ins.
getCustomDocumentProperties() → CustomDocumentPropertiesReturns a collection that represents all the custom document properties of the document.
getProtectionType() → intGets the currently active document protection type.
getSections() → SectionCollectionReturns a collection that represents all sections in the document.
getFirstSection() → SectionGets the first section in the document.
getLastSection() → SectionGets the last section in the document.
getViewOptions() → ViewOptionsProvides options to control how the document is displayed in Microsoft Word.
getWriteProtection() → WriteProtectionProvides access to the document write protection options.
getCompatibilityOptions() → CompatibilityOptionsProvides access to document compatibility options (that is, the user preferences entered on the Compatibility tab of the Options dialog in Word).
getMailMergeSettings() → MailMergeSettingsGets 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() → HyphenationOptionsProvides access to document hyphenation options.
hasRevisions() → booleanReturns true if the document has any tracked changes.
hasMacros() → booleanReturns true if the document has a VBA project (macros).
getWatermark() → WatermarkProvides access to the document watermark.
getVersionsCount() → intGets the number of document versions that was stored in the DOC document.
getDefaultTabStop() → doubleGets or sets the interval (in points) between the default tab stops.
setDefaultTabStop(value: double)Sets the default tab stop value.
getTheme() → ThemeGets the Theme object for this document.
getCustomXmlParts() → CustomXmlPartCollectionGets or sets the collection of Custom XML Data Storage Parts.
setCustomXmlParts(value: CustomXmlPartCollection)Sets the custom xml parts value.
getPackageCustomParts() → CustomPartCollectionGets 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() → VariableCollectionReturns the collection of variables added to a document or template.
getGlossaryDocument() → GlossaryDocumentGets or sets the glossary document within this document or template.
setGlossaryDocument(value: GlossaryDocument)Sets the glossary document value.
getOriginalFileName() → StringGets the original file name of the document.
getOriginalLoadFormat() → intGets the format of the original document that was loaded into this object.
getCompliance() → intGets the OOXML compliance version determined from the loaded document content.
getDigitalSignatures() → DigitalSignatureCollectionGets the collection of digital signatures for this document and their validation results.
getFontSettings() → FontSettingsGets or sets document font settings.
setFontSettings(value: FontSettings)Sets the font settings value.
getBibliography() → BibliographyGets the Bibliography object that represents the list of sources available in the document.
getFrameset() → FramesetReturns a Frameset instance if this document represents a frames page.
getIncludeTextboxesFootnotesEndnotesInStat() → booleanSpecifies whether to include textboxes, footnotes and endnotes in word count statistics.
setIncludeTextboxesFootnotesEndnotesInStat(value: boolean)Sets the include textboxes footnotes endnotes in stat value.
deepClone() → DocumentPerforms a deep copy of the Document.
accept(visitor: DocumentVisitor) → booleanCalls accept(visitor) on this Document instance.
acceptStart(visitor: DocumentVisitor) → intAccepts a visitor for visiting the start of the document.
acceptEnd(visitor: DocumentVisitor) → intAccepts 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) → SaveOutputParametersLimited in the FOSS edition — some inputs are rejected. Saves the document to a file.
save(fileName: String, saveFormat: int) → SaveOutputParametersLimited in the FOSS edition — some inputs are rejected. Saves the document to a file in the specified format.
save(fileName: String, saveOptions: SaveOptions) → SaveOutputParametersLimited 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) → SaveOutputParametersLimited in the FOSS edition — some inputs are rejected. Calls save(stream, saveFormat) on this Document instance.
save(stream: java.io.OutputStream, saveOptions: SaveOptions) → SaveOutputParametersLimited 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) → booleanRemoves 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() → intJoins 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() → RevisionCollectionGets a collection of revisions (tracked changes) that exist in this document.
getRevisionsView() → intGets 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() → intGets or sets the character spacing adjustment of a document.
setJustificationMode(value: int)Sets the justification mode value.
getFootnoteOptions() → FootnoteOptionsProvides options that control numbering and positioning of footnotes in this document.
getEndnoteOptions() → EndnoteOptionsProvides options that control numbering and positioning of endnotes in this document.
getFieldOptions() → FieldOptionsGets a FieldOptions object that represents options to control field handling in the document.
getRemovePersonalInformation() → booleanGets 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() → VbaProjectGets or sets a VbaProject.
setVbaProject(value: VbaProject)Sets the vba project value.

See Also