Esempio n. 1
0
        /**
         * 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.
         *
         * @param elem The Element the RTF document is to be imported into.
         * @param documentSource The Reader to read the RTF document from.
         * @param events The event array for listeners.
         * @throws IOException On errors reading the RTF document.
         * @throws DocumentException On errors adding to this RTF document.
         * @since 2.1.4
         */
        public void ImportRtfDocumentIntoElement(IElement elem, FileStream documentSource, IEventListener[] events)
        {
            RtfParser rtfImport = new RtfParser(this.document);

            if (events != null)
            {
                for (int idx = 0; idx < events.Length; idx++)
                {
                    rtfImport.AddListener(events[idx]);
                }
            }
            rtfImport.ImportRtfDocumentIntoElement(elem, documentSource, rtfDoc);
        }
Esempio n. 2
0
        /**
         * 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.
         *
         * @param documentSource The Stream to read the RTF fragment from.
         * @param mappings The RtfImportMappings that contain font and color mappings to apply to the fragment.
         * @param eventListeners The array of event listeners. May be null
         * @throws IOException On errors reading the RTF fragment.
         * @throws DocumentException On errors adding to this RTF fragment.
         *
         * @see com.lowagie.text.rtf.parser.RtfImportMappings
         * @see com.lowagie.text.rtf.parser.RtfParser
         * @see com.lowagie.text.rtf.parser.RtfParser#importRtfFragment(Reader, RtfDocument, com.lowagie.text.rtf.parser.RtfImportMappings)
         * @since 2.0.8
         * @author Howard Shank
         */
        public void ImportRtfFragment(Stream documentSource, RtfImportMappings mappings, IEventListener[] events)
        {
            if (!this.open)
            {
                throw new DocumentException(MessageLocalization.GetComposedMessage("the.document.must.be.open.to.import.rtf.fragments"));
            }
            RtfParser rtfImport = new RtfParser(this.document);

            if (events != null)
            {
                for (int idx = 0; idx < events.Length; idx++)
                {
                    rtfImport.AddListener(events[idx]);
                }
            }
            rtfImport.ImportRtfFragment(documentSource, this.rtfDoc, mappings);
        }
Esempio n. 3
0
        /**
         * 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.
         *
         * @param documentSource The Stream to read the RTF fragment from.
         * @param mappings The RtfImportMappings that contain font and color mappings to apply to the fragment.
         * @param eventListeners The array of event listeners. May be null
         * @throws IOException On errors reading the RTF fragment.
         * @throws DocumentException On errors adding to this RTF fragment.
         *
         * @see com.lowagie.text.rtf.parser.RtfImportMappings
         * @see com.lowagie.text.rtf.parser.RtfParser
         * @see com.lowagie.text.rtf.parser.RtfParser#importRtfFragment(Reader, RtfDocument, com.lowagie.text.rtf.parser.RtfImportMappings)
         * @since 2.0.8
         * @author Howard Shank
         */
        public void ImportRtfFragment(Stream documentSource, RtfImportMappings mappings, IEventListener[] events)
        {
            if (!this.open)
            {
                throw new DocumentException("The document must be open to import RTF fragments.");
            }
            RtfParser rtfImport = new RtfParser(this.document);

            if (events != null)
            {
                for (int idx = 0; idx < events.Length; idx++)
                {
                    rtfImport.AddListener(events[idx]);
                }
            }
            rtfImport.ImportRtfFragment(documentSource, this.rtfDoc, mappings);
        }
        /// <summary>
        /// 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.
        /// @throws IOException
        /// @throws DocumentException
        /// @see com.lowagie.text.rtf.parser.RtfParser
        /// @see com.lowagie.text.rtf.parser.RtfParser#importRtfDocument(Reader, RtfDocument)
        /// @since 2.0.8
        /// @author Howard Shank
        /// </summary>
        /// <param name="documentSource">The Stream to read the RTF document from.</param>
        /// <param name="events">The array of event listeners. May be null</param>
        public void ImportRtfDocument(Stream documentSource, IEventListener[] events)
        {
            if (!open)
            {
                throw new DocumentException("The document must be open to import RTF documents.");
            }
            RtfParser rtfImport = new RtfParser(Document);

            if (events != null)
            {
                for (int idx = 0; idx < events.Length; idx++)
                {
                    rtfImport.AddListener(events[idx]);
                }
            }
            rtfImport.ImportRtfDocument(documentSource, _rtfDoc);
        }