Package com.independentsoft.office.word
Class WordDocument
java.lang.Object
com.independentsoft.office.OfficeDocument
com.independentsoft.office.word.WordDocument
The Class WordDocument.
-
Field Summary
Fields inherited from class com.independentsoft.office.OfficeDocument
applicationProperty, contentTypeTable, coreProperty, customFileTable, customProperties, documentRelationship, inputFileTable, macro, mainDocumentFileName, mainDocumentFolderName, outputStream, packageRelationship, theme, utf8 -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new word document.WordDocument(InputStream inputStream)Instantiates a new word document.WordDocument(String file)Instantiates a new word document. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendHtml(String htmlContent)Append HTML content to the existing document.clone()Gets the background.getBody()Gets the body.byte[]getBytes()Gets the bytes.Gets the comments.Gets the content elements.Gets the endnotes.Gets the fields.getFonts()Gets the fonts.Gets the footer table.Gets the footnotes.Gets the glossary document.Gets the header table.getHtml()Get HTML representation of the document.Gets the input stream.Get Markdown representation of the document.Gets the mc:Ignorable attribute value of the document root, ornullif absent.Gets the numbering definitions.Gets the paragraphs.Gets the pictures.getRtf()Get RTF representation of the document.getRuns()Gets the runs.Gets the sections.Gets the settings.Gets the style definitions.Gets the tables.getTexts()Gets the texts.getTheme()Gets the document theme.Gets the web settings.voidimportHtml(String htmlContent)Import HTML string content and convert it to Word document structure.booleanChecks if is macro enabled.booleanChecks if is template.voidloadFromDoc(InputStream stream)Loads a DOC document from a stream.voidloadFromDoc(String file)Loads a DOC (Microsoft Word 97-2003 binary format) document and reconstructs its content (text, character/paragraph formatting, styles, tables, fields and embedded PNG/JPEG images) into this document.voidloadFromHtml(InputStream inputStream)Load HTML content from an input stream and convert it to Word document structure.voidloadFromHtml(String filePath)Load HTML content from a file and convert it to Word document structure.voidloadFromRtf(InputStream stream)Loads an RTF document from a stream.voidloadFromRtf(String file)Loads an RTF (Rich Text Format) document and reconstructs its content (text, character/paragraph formatting, tables and embedded PNG/JPEG images) into this document.voidloadFromRtfString(String rtfContent)Loads an RTF document from an RTF markup string.voidopen(InputStream inputStream)Open.voidOpen.protected voidopenImplementation(InputStream inputStream)voidReplace.voidReplace.voidReplace.voidReplace.voidReplace.voidReplace.voidReplace.voidReplace.voidsave(OutputStream outputStream)Save.voidSave.voidSave.voidsaveAsHtml(OutputStream outputStream)Save the document as HTML to the specified output stream.voidsaveAsHtml(String filePath)Save the document as HTML to the specified file path.voidsaveAsHtml(String filePath, boolean overwrite)Save the document as HTML to the specified file path.voidsaveAsMarkdown(OutputStream outputStream)Save the document as Markdown to the specified output stream.voidsaveAsMarkdown(String filePath)Save the document as Markdown to the specified file path.voidsaveAsMarkdown(String filePath, boolean overwrite)Save the document as Markdown to the specified file path.voidsaveAsPdf(OutputStream outputStream)Save the document as PDF to the specified output stream.voidsaveAsPdf(OutputStream outputStream, PdfSaveOptions options)Save the document as PDF to the specified output stream.voidSave the document as PDF to the specified file path.voidSave the document as PDF to the specified file path.voidsaveAsPdf(String filePath, boolean overwrite, PdfSaveOptions options)Save the document as PDF to the specified file path.voidsaveAsPdf(String filePath, PdfSaveOptions options)Save the document as PDF to the specified file path.voidsaveAsRtf(OutputStream outputStream)Save the document as RTF to the specified output stream.voidSave the document as RTF to the specified file path.voidSave the document as RTF to the specified file path.voidsetBackground(Background background)Sets the background.voidsetGlossaryDocument(GlossaryDocument glossaryDocument)Sets the glossary document.voidsetMacroEnabled(boolean isMacroEnabled)Sets the macro enabled.voidsetMarkupCompatibilityIgnorable(String markupCompatibilityIgnorable)Sets the mc:Ignorable attribute value of the document root.voidsetNumberingDefinitions(NumberingDefinitions numberingDefinitions)Sets the numbering definitions.voidsetStyleDefinitions(StyleDefinitions styleDefinitions)Sets the style definitions.voidsetTemplate(boolean isTemplate)Sets the template.toString()toText()To text.Methods inherited from class com.independentsoft.office.OfficeDocument
addFile, addFile, getApplicationName, getApplicationVersion, getCategory, getCharacterCount, getCompany, getContentStatus, getContentType, getContentTypeTable, getCreated, getCreator, getCustomFileTable, getCustomProperties, getDescription, getDigitalSignature, getDocumentSecurity, getHeadingPairs, getHiddenSlideCount, getHyperlinkList, getIdentifier, getInputFileTable, getKeywords, getLanguage, getLastCharacterCount, getLastModifiedBy, getLastPrinted, getLineCount, getMacro, getMainDocumentFolderName, getManager, getModified, getMultimediaClipCount, getNoteCount, getPageCount, getParagraphCount, getPartTitles, getPresentationFormat, getRelativeHyperlinkBase, getRevision, getSubject, getTemplateName, getTitle, getTotalTime, getVersion, getWordCount, hasEnableScaling, hasHyperlinksChanged, hasLinksUpToDate, isSharedDocument, setApplicationName, setApplicationVersion, setCategory, setCharacterCount, setCompany, setContentStatus, setContentType, setCreated, setCreator, setDescription, setDigitalSignature, setDocumentSecurity, setEnableScaling, setHeadingPairs, setHiddenSlideCount, setHyperlinkList, setHyperlinksChanged, setIdentifier, setKeywords, setLanguage, setLastCharacterCount, setLastModifiedBy, setLastPrinted, setLineCount, setLinksUpToDate, setMacro, setManager, setModified, setMultimediaClipCount, setNoteCount, setPageCount, setParagraphCount, setPartTitles, setPresentationFormat, setRelativeHyperlinkBase, setRevision, setSharedDocument, setSubject, setTemplateName, setTheme, setTitle, setTotalTime, setVersion, setWordCount
-
Constructor Details
-
WordDocument
public WordDocument()Instantiates a new word document. -
WordDocument
Instantiates a new word document.- Parameters:
file- the file- Throws:
IOException- Signals that an I/O exception has occurred.XMLStreamException- the xML stream exception
-
WordDocument
Instantiates a new word document.- Parameters:
inputStream- the input stream- Throws:
IOException- Signals that an I/O exception has occurred.XMLStreamException- the xML stream exception
-
-
Method Details
-
open
Description copied from class:OfficeDocumentOpen.- Specified by:
openin classOfficeDocument- Parameters:
filePath- the file- Throws:
IOException- Signals that an I/O exception has occurred.XMLStreamException- the xML stream exception
-
open
Description copied from class:OfficeDocumentOpen.- Specified by:
openin classOfficeDocument- Parameters:
inputStream- the stream- Throws:
IOException- Signals that an I/O exception has occurred.XMLStreamException- the xML stream exception
-
loadFromDoc
Loads a DOC (Microsoft Word 97-2003 binary format) document and reconstructs its content (text, character/paragraph formatting, styles, tables, fields and embedded PNG/JPEG images) into this document.- Parameters:
file- the DOC file path- Throws:
IOException- Signals that an I/O exception has occurred.
-
loadFromDoc
Loads a DOC document from a stream. SeeloadFromDoc(String).- Parameters:
stream- the DOC stream- Throws:
IOException- Signals that an I/O exception has occurred.
-
loadFromRtf
Loads an RTF (Rich Text Format) document and reconstructs its content (text, character/paragraph formatting, tables and embedded PNG/JPEG images) into this document.- Parameters:
file- the RTF file path- Throws:
IOException- Signals that an I/O exception has occurred.
-
loadFromRtf
Loads an RTF document from a stream. SeeloadFromRtf(String).- Parameters:
stream- the RTF stream- Throws:
IOException- Signals that an I/O exception has occurred.
-
loadFromRtfString
Loads an RTF document from an RTF markup string.- Parameters:
rtfContent- the RTF markup
-
openImplementation
- Overrides:
openImplementationin classOfficeDocument- Throws:
IOExceptionXMLStreamException
-
save
Description copied from class:OfficeDocumentSave.- Specified by:
savein classOfficeDocument- Parameters:
filePath- the file- Throws:
IOException- Signals that an I/O exception has occurred.
-
save
Description copied from class:OfficeDocumentSave.- Specified by:
savein classOfficeDocument- Parameters:
filePath- the fileoverwrite- the overwrite- Throws:
IOException- Signals that an I/O exception has occurred.
-
save
Description copied from class:OfficeDocumentSave.- Specified by:
savein classOfficeDocument- Parameters:
outputStream- the stream- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsHtml
Save the document as HTML to the specified file path.- Parameters:
filePath- the file path- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsHtml
Save the document as HTML to the specified file path.- Parameters:
filePath- the file pathoverwrite- whether to overwrite existing file- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsHtml
Save the document as HTML to the specified output stream.- Parameters:
outputStream- the output stream- Throws:
IOException- Signals that an I/O exception has occurred.
-
getHtml
Get HTML representation of the document.- Returns:
- HTML string representation of the document
-
saveAsPdf
Save the document as PDF to the specified file path.- Parameters:
filePath- the file path- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsPdf
Save the document as PDF to the specified file path.- Parameters:
filePath- the file pathoptions- the PDF export options- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsPdf
Save the document as PDF to the specified file path.- Parameters:
filePath- the file pathoverwrite- whether to overwrite existing file- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsPdf
public void saveAsPdf(String filePath, boolean overwrite, PdfSaveOptions options) throws IOExceptionSave the document as PDF to the specified file path.- Parameters:
filePath- the file pathoverwrite- whether to overwrite existing fileoptions- the PDF export options- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsPdf
Save the document as PDF to the specified output stream.- Parameters:
outputStream- the output stream- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsPdf
Save the document as PDF to the specified output stream.- Parameters:
outputStream- the output streamoptions- the PDF export options- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsRtf
Save the document as RTF to the specified file path.- Parameters:
filePath- the file path- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsRtf
Save the document as RTF to the specified file path.- Parameters:
filePath- the file pathoverwrite- whether to overwrite existing file- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsRtf
Save the document as RTF to the specified output stream.- Parameters:
outputStream- the output stream- Throws:
IOException- Signals that an I/O exception has occurred.
-
getRtf
Get RTF representation of the document.- Returns:
- RTF string representation of the document
-
saveAsMarkdown
Save the document as Markdown to the specified file path.- Parameters:
filePath- the file path- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsMarkdown
Save the document as Markdown to the specified file path.- Parameters:
filePath- the file pathoverwrite- whether to overwrite existing file- Throws:
IOException- Signals that an I/O exception has occurred.
-
saveAsMarkdown
Save the document as Markdown to the specified output stream.- Parameters:
outputStream- the output stream- Throws:
IOException- Signals that an I/O exception has occurred.
-
getMarkdown
Get Markdown representation of the document.- Returns:
- Markdown string representation of the document
-
loadFromHtml
Load HTML content from a file and convert it to Word document structure. This replaces the current document content.- Parameters:
filePath- the path to the HTML file- Throws:
IOException- Signals that an I/O exception has occurred.
-
loadFromHtml
Load HTML content from an input stream and convert it to Word document structure. This replaces the current document content.- Parameters:
inputStream- the input stream containing HTML content- Throws:
IOException- Signals that an I/O exception has occurred.
-
importHtml
Import HTML string content and convert it to Word document structure. This replaces the current document content.- Parameters:
htmlContent- the HTML content string
-
appendHtml
Append HTML content to the existing document.- Parameters:
htmlContent- the HTML content string to append
-
getInputStream
Description copied from class:OfficeDocumentGets the input stream.- Specified by:
getInputStreamin classOfficeDocument- Returns:
- the input stream
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getBytes
Description copied from class:OfficeDocumentGets the bytes.- Specified by:
getBytesin classOfficeDocument- Returns:
- the bytes
- Throws:
IOException- Signals that an I/O exception has occurred.
-
getFields
Gets the fields.- Returns:
- the fields
-
getSections
Gets the sections.- Returns:
- the sections
-
getTables
Gets the tables.- Returns:
- the tables
-
getParagraphs
Gets the paragraphs.- Returns:
- the paragraphs
-
getRuns
Gets the runs.- Returns:
- the runs
-
getTexts
Gets the texts.- Returns:
- the texts
-
getPictures
Gets the pictures.- Returns:
- the pictures
-
replace
Replace.- Parameters:
oldText- the old textnewText- the new text
-
replace
Replace.- Parameters:
oldText- the old textnewText- the new textreplaceIn- the replace in
-
replace
Replace.- Parameters:
oldText- the old textnewText- the new text
-
replace
Replace.- Parameters:
oldText- the old textnewText- the new textreplaceIn- the replace in
-
replace
Replace.- Parameters:
text- the textrun- the run
-
replace
Replace.- Parameters:
text- the textrun- the runreplaceIn- the replace in
-
replace
Replace.- Parameters:
text- the textruns- the runs
-
replace
Replace.- Parameters:
text- the textruns- the runsreplaceIn- the replace in
-
getContentElements
Gets the content elements.- Returns:
- the content elements
-
clone
-
toString
-
toText
To text.- Returns:
- the string
-
isTemplate
public boolean isTemplate()Checks if is template.- Returns:
- true, if is template
-
setTemplate
public void setTemplate(boolean isTemplate)Sets the template.- Parameters:
isTemplate- the new template
-
isMacroEnabled
public boolean isMacroEnabled()Checks if is macro enabled.- Returns:
- true, if is macro enabled
-
setMacroEnabled
public void setMacroEnabled(boolean isMacroEnabled)Sets the macro enabled.- Parameters:
isMacroEnabled- the new macro enabled
-
getBody
Gets the body.- Returns:
- the body
-
getMarkupCompatibilityIgnorable
Gets the mc:Ignorable attribute value of the document root, ornullif absent.- Returns:
- the markup-compatibility ignorable prefixes
-
setMarkupCompatibilityIgnorable
Sets the mc:Ignorable attribute value of the document root.- Parameters:
markupCompatibilityIgnorable- the new value
-
getGlossaryDocument
Gets the glossary document.- Returns:
- the glossary document
-
setGlossaryDocument
Sets the glossary document.- Parameters:
glossaryDocument- the new glossary document
-
getBackground
Gets the background.- Returns:
- the background
-
setBackground
Sets the background.- Parameters:
background- the new background
-
getStyleDefinitions
Gets the style definitions.- Returns:
- the style definitions
-
setStyleDefinitions
Sets the style definitions.- Parameters:
styleDefinitions- the new style definitions
-
getNumberingDefinitions
Gets the numbering definitions.- Returns:
- the numbering definitions
-
setNumberingDefinitions
Sets the numbering definitions.- Parameters:
numberingDefinitions- the new numbering definitions
-
getFonts
Gets the fonts.- Returns:
- the fonts
-
getSettings
Gets the settings.- Returns:
- the settings
-
getWebSettings
Gets the web settings.- Returns:
- the web settings
-
getComments
Gets the comments.- Returns:
- the comments
-
getFootnotes
Gets the footnotes.- Returns:
- the footnotes
-
getEndnotes
Gets the endnotes.- Returns:
- the endnotes
-
getHeaderTable
Gets the header table.- Returns:
- the header table
-
getTheme
Gets the document theme.- Overrides:
getThemein classOfficeDocument- Returns:
- the theme
-