Class RtfWriter2

  • All Implemented Interfaces:
    DocListener, ElementListener, java.util.EventListener

    public class RtfWriter2
    extends DocWriter
    The RtfWriter allows the creation of rtf documents via the iText system Version: $Id: RtfWriter2.java 3583 2008-08-12 00:00:09Z xlv $
    Author:
    Mark Hall (Mark.Hall@mail.room3b.eu)
    • Field Detail

      • rtfDoc

        private RtfDocument rtfDoc
        The RtfDocument this RtfWriter is creating
    • Constructor Detail

      • RtfWriter2

        protected RtfWriter2​(Document doc,
                             java.io.OutputStream os)
        Constructs a new RtfWriter that listens to the specified Document and writes its output to the OutputStream.
        Parameters:
        doc - The Document that this RtfWriter listens to
        os - The OutputStream to write to
    • Method Detail

      • getInstance

        public static RtfWriter2 getInstance​(Document doc,
                                             java.io.OutputStream os)
        Static method to generate RtfWriters
        Parameters:
        doc - The Document that this RtfWriter listens to
        os - The OutputStream to write to
        Returns:
        The new RtfWriter
      • setPageCount

        public void setPageCount​(int i)
        This method is not supported in the RtfWriter
        Specified by:
        setPageCount in interface DocListener
        Overrides:
        setPageCount in class DocWriter
        Parameters:
        i - Unused
      • clearTextWrap

        public void clearTextWrap()
        This method is not supported in the RtfWriter
      • close

        public void close()
        Closes the RtfDocument. This causes the document to be written to the specified OutputStream
        Specified by:
        close in interface DocListener
        Overrides:
        close in class DocWriter
      • setMargins

        public boolean setMargins​(float left,
                                  float right,
                                  float top,
                                  float bottom)
        Sets the page margins
        Specified by:
        setMargins in interface DocListener
        Overrides:
        setMargins in class DocWriter
        Parameters:
        left - The left margin
        right - The right margin
        top - The top margin
        bottom - The bottom margin
        Returns:
        false
      • setAutogenerateTOCEntries

        public void setAutogenerateTOCEntries​(boolean autogenerate)
        Whether to automagically generate table of contents entries when adding Chapters or Sections.
        Parameters:
        autogenerate - Whether to automatically generate TOC entries
      • getDocumentSettings

        public RtfDocumentSettings getDocumentSettings()
        Gets the RtfDocumentSettings that specify how the rtf document is generated.
        Returns:
        The current RtfDocumentSettings.
      • importRtfDocument

        public void importRtfDocument​(java.io.FileInputStream documentSource)
                               throws java.io.IOException,
                                      DocumentException
        Adds the complete RTF document to the current RTF document being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings.
        Parameters:
        documentSource - The Reader to read the RTF document from.
        Throws:
        java.io.IOException - On errors reading the RTF document.
        DocumentException - On errors adding to this RTF document.
        Since:
        2.1.0
      • importRtfDocument

        public void importRtfDocument​(java.io.InputStream documentSource,
                                      java.util.EventListener[] events)
                               throws java.io.IOException,
                                      DocumentException
        Adds the complete RTF document to the current RTF document being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings. Uses new RtfParser object. (author: Howard Shank)
        Parameters:
        documentSource - The InputStream to read the RTF document from.
        events - The array of event listeners. May be null
        Throws:
        java.io.IOException
        DocumentException
        Since:
        2.0.8
        See Also:
        RtfParser, RtfParser.importRtfDocument(InputStream, RtfDocument)
      • importRtfFragment

        public void importRtfFragment​(java.io.InputStream documentSource,
                                      RtfImportMappings mappings)
                               throws java.io.IOException,
                                      DocumentException
        Adds a fragment of an RTF document to the current RTF document being generated. Since this fragment doesn't contain font or color tables, all fonts and colors are mapped to the default font and color. If the font and color mappings are known, they can be specified via the mappings parameter.
        Parameters:
        documentSource - The InputStream to read the RTF fragment from.
        mappings - The RtfImportMappings that contain font and color mappings to apply to the fragment.
        Throws:
        java.io.IOException - On errors reading the RTF fragment.
        DocumentException - On errors adding to this RTF fragment.
        Since:
        2.1.0
      • importRtfFragment

        public void importRtfFragment​(java.io.InputStream documentSource,
                                      RtfImportMappings mappings,
                                      java.util.EventListener[] events)
                               throws java.io.IOException,
                                      DocumentException
        Adds a fragment of an RTF document to the current RTF document being generated. Since this fragment doesn't contain font or color tables, all fonts and colors are mapped to the default font and color. If the font and color mappings are known, they can be specified via the mappings parameter. Uses new RtfParser object. (author: Howard Shank)
        Parameters:
        documentSource - The InputStream to read the RTF fragment from.
        mappings - The RtfImportMappings that contain font and color mappings to apply to the fragment.
        events - The array of event listeners. May be null
        Throws:
        java.io.IOException - On errors reading the RTF fragment.
        DocumentException - On errors adding to this RTF fragment.
        Since:
        2.0.8
        See Also:
        RtfImportMappings, RtfParser, RtfParser.importRtfFragment(InputStream, RtfDocument, RtfImportMappings)
      • importRtfDocumentIntoElement

        public void importRtfDocumentIntoElement​(Element elem,
                                                 java.io.FileInputStream documentSource)
                                          throws java.io.IOException,
                                                 DocumentException
        Adds the complete RTF document to the current RTF element being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings.
        Parameters:
        elem - The Element the RTF document is to be imported into.
        documentSource - The Reader to read the RTF document from.
        Throws:
        java.io.IOException - On errors reading the RTF document.
        DocumentException - On errors adding to this RTF document.
        Since:
        2.1.4
      • importRtfDocumentIntoElement

        public void importRtfDocumentIntoElement​(Element elem,
                                                 java.io.FileInputStream documentSource,
                                                 java.util.EventListener[] events)
                                          throws java.io.IOException,
                                                 DocumentException
        Adds the complete RTF document to the current RTF element being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings.
        Parameters:
        elem - The Element the RTF document is to be imported into.
        documentSource - The Reader to read the RTF document from.
        events - The event array for listeners.
        Throws:
        java.io.IOException - On errors reading the RTF document.
        DocumentException - On errors adding to this RTF document.
        Since:
        2.1.4