Package com.independentsoft.office.odf

# Class TextDocument

java.lang.Object
com.independentsoft.office.odf.Document
com.independentsoft.office.odf.TextDocument

public class TextDocument extends Document
The Class TextDocument.

- ## Field Summary

  ### Fields inherited from class com.independentsoft.office.odf.Document

  `commonStyles, customFileTable, inputFileTable, isTemplate, manifest, metaData, mimeType, outputStream, settings, utf8`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TextDocument()`
  Instantiates a new text document.
  `TextDocument​(InputStream inputStream)`
  Instantiates a new text document.
  `TextDocument​(String file)`
  Instantiates a new text document.
  `TextDocument​(String folder, FileTable inputFileTable)`
  Instantiates a new text document.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `TextDocument`
  `clone()`
  Creates a new object that is a deep copy of the current instance.
  `AutomaticStyles`
  `getAutomaticStyles()`
  Gets the automatic styles.
  `TextDocumentBody`
  `getBody()`
  Gets the body.
  `byte[]`
  `getBytes()`
  Gets the bytes.
  `TextDocumentContent`
  `getContent()`
  Gets the content.
  `List<IContentElement>`
  `getContentElements()`
  Returns all content elements.
  `List<Font>`
  `getFonts()`
  Gets the fonts.
  `OfficeForms`
  `getForms()`
  Gets the forms.
  `byte[]`
  `getHtmlBytes()`
  Get HTML representation of the document as a byte array.
  `InputStream`
  `getInputStream()`
  Gets the input stream.
  `byte[]`
  `getMarkdownBytes()`
  Gets the Markdown bytes.
  `OfficeScripts`
  `getOfficeScripts()`
  Gets the office scripts.
  `byte[]`
  `getPdfBytes()`
  Gets the PDF bytes.
  `byte[]`
  `getPdfBytes​(PdfSaveOptions options)`
  Gets the PDF bytes.
  `byte[]`
  `getRtfBytes()`
  Gets the RTF bytes.
  `List<SequenceVariableDeclaration>`
  `getSequenceVariableDeclarations()`
  Gets the sequence variable declarations.
  `List<SimpleVariableDeclaration>`
  `getSimpleVariableDeclarations()`
  Gets the simple variable declarations.
  `TrackedChanges`
  `getTrackedChanges()`
  Gets the tracked changes.
  `List<UserVariableDeclaration>`
  `getUserVariableDeclarations()`
  Gets the user variable declarations.
  `boolean`
  `isGlobal()`
  Checks if is global.
  `void`
  `open​(InputStream inputStream)`
  Open.
  `void`
  `open​(String filePath)`
  Open.
  `protected void`
  `openImplementation​(InputStream inputStream)`
  `void`
  `renameStyle​(Style style, String newName)`
  Rename style.
  `void`
  `save​(OutputStream outputStream)`
  Save.
  `void`
  `save​(String filePath)`
  Save.
  `void`
  `save​(String filePath, boolean overwrite)`
  Save.
  `void`
  `saveAsHtml​(OutputStream htmlOutputStream)`
  Save the document as HTML to the specified output stream.
  `void`
  `saveAsHtml​(String filePath)`
  Save the document as HTML to the specified file path.
  `void`
  `saveAsHtml​(String filePath, boolean overwrite)`
  Save the document as HTML to the specified file path.
  `void`
  `saveAsMarkdown​(OutputStream mdOutputStream)`
  Saves the document as Markdown to an output stream.
  `void`
  `saveAsMarkdown​(String filePath)`
  Saves the document as Markdown file.
  `void`
  `saveAsMarkdown​(String filePath, boolean overwrite)`
  Saves the document as Markdown file.
  `void`
  `saveAsPdf​(OutputStream pdfOutputStream)`
  Saves the document as PDF to an output stream.
  `void`
  `saveAsPdf​(OutputStream pdfOutputStream, PdfSaveOptions options)`
  Saves the document as PDF to an output stream.
  `void`
  `saveAsPdf​(String filePath)`
  Saves the document as PDF file.
  `void`
  `saveAsPdf​(String filePath, boolean overwrite)`
  Saves the document as PDF file.
  `void`
  `saveAsPdf​(String filePath, boolean overwrite, PdfSaveOptions options)`
  Saves the document as PDF file.
  `void`
  `saveAsPdf​(String filePath, PdfSaveOptions options)`
  Saves the document as PDF file.
  `void`
  `saveAsRtf​(OutputStream rtfOutputStream)`
  Saves the document as RTF to an output stream.
  `void`
  `saveAsRtf​(String filePath)`
  Saves the document as RTF file.
  `void`
  `saveAsRtf​(String filePath, boolean overwrite)`
  Saves the document as RTF file.
  `void`
  `setForms​(OfficeForms forms)`
  Sets the forms.
  `void`
  `setGlobal​(boolean global)`
  Sets the global.
  `void`
  `setTrackedChanges​(TrackedChanges trackedChanges)`
  Sets the tracked changes.
  `void`
  `setUseSoftPageBreaks​(boolean useSoftPageBreaks)`
  Sets the use soft page breaks.
  `String`
  `toText()`
  To text.
  `boolean`
  `useSoftPageBreaks()`
  Use soft page breaks.

  ### Methods inherited from class com.independentsoft.office.odf.Document

  `addFile, addFile, addManifestEntry, addMimeTypeFile, getAttributedTexts, getCommonStyles, getConfigurations, getCreationDate, getCreator, getCustomFileTable, getDescription, getEditingCycles, getEditingDuration, getFields, getFileInputTable, getGenerator, getHeadings, getImages, getInitialCreator, getInputFileTable, getKeywords, getLanguage, getLastModified, getLists, getManifest, getMetaData, getMimeType, getParagraphs, getPreservedPackageParts, getPrintDate, getPrintedBy, getSections, getStatistic, getSubject, getTables, getTemplate, getTexts, getTitle, getUserDefinedMetadataElements, isTemplate, replace, replace, setCreationDate, setCreator, setDescription, setEditingCycles, setEditingDuration, setInitialCreator, setKeywords, setLanguage, setLastModified, setMimeType, setPrintDate, setPrintedBy, setStatistic, setSubject, setTemplate, setTemplate, setTitle`

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### TextDocument

    public TextDocument()
    Instantiates a new text document.

  - ### TextDocument

    public TextDocument​(String file) throws IOException, XMLStreamException
    Instantiates a new text document.
    Parameters:
      `file` - the file
    Throws:
      `IOException` - Signals that an I/O exception has occurred.
      `XMLStreamException` - the xML stream exception

  - ### TextDocument

    public TextDocument​(InputStream inputStream) throws IOException, XMLStreamException
    Instantiates a new text document.
    Parameters:
      `inputStream` - the input stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.
      `XMLStreamException` - the xML stream exception

  - ### TextDocument

    public TextDocument​(String folder, FileTable inputFileTable) throws IOException, XMLStreamException
    Instantiates a new text document.
    Parameters:
      `folder` - the folder
      `inputFileTable` - the input file table
    Throws:
      `IOException` - Signals that an I/O exception has occurred.
      `XMLStreamException` - the xML stream exception

- ## Method Details

  - ### open

    public void open​(String filePath) throws IOException, XMLStreamException
    Description copied from class: `Document`
    Open.
    Specified by:
      `open` in class `Document`
    Parameters:
      `filePath` - the file
    Throws:
      `IOException` - Signals that an I/O exception has occurred.
      `XMLStreamException` - the xML stream exception

  - ### open

    public void open​(InputStream inputStream) throws IOException, XMLStreamException
    Description copied from class: `Document`
    Open.
    Specified by:
      `open` in class `Document`
    Parameters:
      `inputStream` - the stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.
      `XMLStreamException` - the xML stream exception

  - ### openImplementation

    protected void openImplementation​(InputStream inputStream) throws IOException, XMLStreamException
    Overrides:
      `openImplementation` in class `Document`
    Throws:
      `IOException`
      `XMLStreamException`

  - ### renameStyle

    public void renameStyle​(Style style, String newName)
    Rename style.
    Parameters:
      `style` - the style
      `newName` - the new name

  - ### getContentElements

    public List<IContentElement> getContentElements()
    Returns all content elements.
    Specified by:
      `getContentElements` in class `Document`
    Returns:
      A collection of content elements.

  - ### clone

    public TextDocument clone()
    Creates a new object that is a deep copy of the current instance.
    Overrides:
      `clone` in class `Object`
    Returns:
      A new object that is a copy of this instance.

  - ### save

    public void save​(String filePath) throws IOException
    Description copied from class: `Document`
    Save.
    Specified by:
      `save` in class `Document`
    Parameters:
      `filePath` - the file
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### save

    public void save​(String filePath, boolean overwrite) throws IOException
    Description copied from class: `Document`
    Save.
    Specified by:
      `save` in class `Document`
    Parameters:
      `filePath` - the file
      `overwrite` - the overwrite
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### save

    public void save​(OutputStream outputStream) throws IOException
    Description copied from class: `Document`
    Save.
    Specified by:
      `save` in class `Document`
    Parameters:
      `outputStream` - the stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getInputStream

    public InputStream getInputStream() throws IOException
    Description copied from class: `Document`
    Gets the input stream.
    Specified by:
      `getInputStream` in class `Document`
    Returns:
      the input stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getBytes

    public byte[] getBytes() throws IOException
    Description copied from class: `Document`
    Gets the bytes.
    Specified by:
      `getBytes` in class `Document`
    Returns:
      the bytes
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### toText

    public String toText()
    To text.
    Returns:
      the string

  - ### saveAsRtf

    public void saveAsRtf​(String filePath) throws IOException
    Saves the document as RTF file.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsRtf

    public void saveAsRtf​(String filePath, boolean overwrite) throws IOException
    Saves the document as RTF file.
    Parameters:
      `filePath` - the file path
      `overwrite` - the overwrite
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsRtf

    public void saveAsRtf​(OutputStream rtfOutputStream) throws IOException
    Saves the document as RTF to an output stream.
    Parameters:
      `rtfOutputStream` - the output stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getRtfBytes

    public byte[] getRtfBytes() throws IOException
    Gets the RTF bytes.
    Returns:
      the RTF bytes
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsMarkdown

    public void saveAsMarkdown​(String filePath) throws IOException
    Saves the document as Markdown file.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsMarkdown

    public void saveAsMarkdown​(String filePath, boolean overwrite) throws IOException
    Saves the document as Markdown file.
    Parameters:
      `filePath` - the file path
      `overwrite` - the overwrite
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsMarkdown

    public void saveAsMarkdown​(OutputStream mdOutputStream) throws IOException
    Saves the document as Markdown to an output stream.
    Parameters:
      `mdOutputStream` - the output stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getMarkdownBytes

    public byte[] getMarkdownBytes() throws IOException
    Gets the Markdown bytes.
    Returns:
      the Markdown bytes
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsHtml

    public void saveAsHtml​(String filePath) throws IOException
    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

    public void saveAsHtml​(String filePath, boolean overwrite) throws IOException
    Save the document as HTML to the specified file path.
    Parameters:
      `filePath` - the file path
      `overwrite` - whether to overwrite existing file
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsHtml

    public void saveAsHtml​(OutputStream htmlOutputStream) throws IOException
    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.

  - ### getHtmlBytes

    public byte[] getHtmlBytes() throws IOException
    Get HTML representation of the document as a byte array.
    Returns:
      the HTML bytes
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsPdf

    public void saveAsPdf​(String filePath) throws IOException
    Saves the document as PDF file.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsPdf

    public void saveAsPdf​(String filePath, PdfSaveOptions options) throws IOException
    Saves the document as PDF file.
    Parameters:
      `filePath` - the file path
      `options` - the PDF export options
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsPdf

    public void saveAsPdf​(String filePath, boolean overwrite) throws IOException
    Saves the document as PDF file.
    Parameters:
      `filePath` - the file path
      `overwrite` - the overwrite
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsPdf

    public void saveAsPdf​(String filePath, boolean overwrite, PdfSaveOptions options) throws IOException
    Saves the document as PDF file.
    Parameters:
      `filePath` - the file path
      `overwrite` - the overwrite
      `options` - the PDF export options
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsPdf

    public void saveAsPdf​(OutputStream pdfOutputStream) throws IOException
    Saves the document as PDF to an output stream.
    Parameters:
      `pdfOutputStream` - the output stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsPdf

    public void saveAsPdf​(OutputStream pdfOutputStream, PdfSaveOptions options) throws IOException
    Saves the document as PDF to an output stream.
    Parameters:
      `pdfOutputStream` - the output stream
      `options` - the PDF export options
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getPdfBytes

    public byte[] getPdfBytes() throws IOException
    Gets the PDF bytes.
    Returns:
      the PDF bytes
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getPdfBytes

    public byte[] getPdfBytes​(PdfSaveOptions options) throws IOException
    Gets the PDF bytes.
    Parameters:
      `options` - the PDF export options
    Returns:
      the PDF bytes
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getBody

    public TextDocumentBody getBody()
    Gets the body.
    Returns:
      the body

  - ### getFonts

    public List<Font> getFonts()
    Gets the fonts.
    Returns:
      the fonts

  - ### getOfficeScripts

    public OfficeScripts getOfficeScripts()
    Gets the office scripts.
    Returns:
      the office scripts

  - ### getAutomaticStyles

    public AutomaticStyles getAutomaticStyles()
    Gets the automatic styles.
    Returns:
      the automatic styles

  - ### getSimpleVariableDeclarations

    public List<SimpleVariableDeclaration> getSimpleVariableDeclarations()
    Gets the simple variable declarations.
    Returns:
      the simple variable declarations

  - ### getSequenceVariableDeclarations

    public List<SequenceVariableDeclaration> getSequenceVariableDeclarations()
    Gets the sequence variable declarations.
    Returns:
      the sequence variable declarations

  - ### getUserVariableDeclarations

    public List<UserVariableDeclaration> getUserVariableDeclarations()
    Gets the user variable declarations.
    Returns:
      the user variable declarations

  - ### getTrackedChanges

    public TrackedChanges getTrackedChanges()
    Gets the tracked changes.
    Returns:
      the tracked changes

  - ### setTrackedChanges

    public void setTrackedChanges​(TrackedChanges trackedChanges)
    Sets the tracked changes.
    Parameters:
      `trackedChanges` - the new tracked changes

  - ### getForms

    public OfficeForms getForms()
    Gets the forms.
    Returns:
      the forms

  - ### setForms

    public void setForms​(OfficeForms forms)
    Sets the forms.
    Parameters:
      `forms` - the new forms

  - ### isGlobal

    public boolean isGlobal()
    Checks if is global.
    Returns:
      true, if is global

  - ### setGlobal

    public void setGlobal​(boolean global)
    Sets the global.
    Parameters:
      `global` - the new global

  - ### useSoftPageBreaks

    public boolean useSoftPageBreaks()
    Use soft page breaks.
    Returns:
      true, if successful

  - ### setUseSoftPageBreaks

    public void setUseSoftPageBreaks​(boolean useSoftPageBreaks)
    Sets the use soft page breaks.
    Parameters:
      `useSoftPageBreaks` - the new use soft page breaks

  - ### getContent

    public TextDocumentContent getContent()
    Gets the content.
    Returns:
      the content