Class TextDocument

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

public class TextDocument extends Document
The Class TextDocument.
  • Constructor Details

  • 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