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.
  `String`
  `getHtml()`
  Converts the document to HTML format.
  `InputStream`
  `getInputStream()`
  Gets the input stream.
  `OfficeScripts`
  `getOfficeScripts()`
  Gets the office scripts.
  `byte[]`
  `getPdfBytes()`
  Gets the PDF bytes.
  `byte[]`
  `getPdfBytes​(PdfSaveOptions options)`
  Gets the PDF 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 stream)`
  Saves the document in HTML format.
  `void`
  `saveAsHtml​(String file)`
  Saves the document in HTML format.
  `void`
  `saveAsHtml​(String file, boolean overwrite)`
  Saves the document in HTML format.
  `void`
  `saveAsMarkdown​(OutputStream stream)`
  Saves the document in Markdown format.
  `void`
  `saveAsMarkdown​(String file)`
  Saves the document in Markdown format.
  `void`
  `saveAsMarkdown​(String file, boolean overwrite)`
  Saves the document in Markdown format.
  `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 stream)`
  Saves the document in RTF format.
  `void`
  `saveAsRtf​(String file)`
  Saves the document in RTF format.
  `void`
  `saveAsRtf​(String file, boolean overwrite)`
  Saves the document in RTF format.
  `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`
  `toMarkdown()`
  Returns the document content as a Markdown string.
  `String`
  `toRtf()`
  Converts the document to RTF format.
  `boolean`
  `useSoftPageBreaks()`
  Use soft page breaks.

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

  `addFile, addFile, addManifestEntry, addMimeTypeFile, addPreservedEmbeddedObjectManifestEntries, find, find, findElements, findElements, findElements, findFirst, findFirst, 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, getText, getTexts, getTitle, getUserDefinedMetadataElements, isTemplate, remove, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replace, replaceContent, 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.

  - ### saveAsMarkdown

    public void saveAsMarkdown​(String file) throws IOException
    Saves the document in Markdown format.
    Parameters:
      `file` - The path of the file to save.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsMarkdown

    public void saveAsMarkdown​(String file, boolean overwrite) throws IOException
    Saves the document in Markdown format.
    Parameters:
      `file` - The path of the file to save.
      `overwrite` - If true, overwrites the existing file.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsMarkdown

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

  - ### toMarkdown

    public String toMarkdown()
    Returns the document content as a Markdown string.
    Returns:
      A Markdown string.

  - ### saveAsRtf

    public void saveAsRtf​(String file) throws IOException
    Saves the document in RTF format.
    Parameters:
      `file` - The path of the file to save.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsRtf

    public void saveAsRtf​(String file, boolean overwrite) throws IOException
    Saves the document in RTF format.
    Parameters:
      `file` - The path of the file to save.
      `overwrite` - If true, overwrites an existing file.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsRtf

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

  - ### toRtf

    public String toRtf()
    Converts the document to RTF format.
    Returns:
      The RTF representation of the document.

  - ### saveAsHtml

    public void saveAsHtml​(String file) throws IOException
    Saves the document in HTML format.
    Specified by:
      `saveAsHtml` in class `Document`
    Parameters:
      `file` - The path of the file to save.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsHtml

    public void saveAsHtml​(String file, boolean overwrite) throws IOException
    Saves the document in HTML format.
    Specified by:
      `saveAsHtml` in class `Document`
    Parameters:
      `file` - The path of the file to save.
      `overwrite` - If true, overwrites an existing file.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### saveAsHtml

    public void saveAsHtml​(OutputStream stream) throws IOException
    Saves the document in HTML format.
    Specified by:
      `saveAsHtml` in class `Document`
    Parameters:
      `stream` - The stream to save to.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getHtml

    public String getHtml() throws IOException
    Converts the document to HTML format.
    Specified by:
      `getHtml` in class `Document`
    Returns:
      The HTML representation of the document.
    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