Exemple #1
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.
         *
         * @param documentSource The Reader to read the RTF fragment from.
         * @param mappings The RtfImportMappings that contain font and color mappings to apply to the fragment.
         * @throws IOException On errors reading the RTF fragment.
         * @throws DocumentException On errors adding to this RTF fragment.
         */
        public void ImportRtfFragment(TextReader documentSource, RtfImportMappings mappings)
        {
            if (!this.open)
            {
                throw new DocumentException("The document must be open to import RTF fragments.");
            }
            RtfParser rtfImport = new RtfParser();

            rtfImport.ImportRtfFragment(documentSource, this.rtfDoc, mappings);
        }
Exemple #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("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);
        }
Exemple #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(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);
        }
Exemple #4
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.
  *
  * @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.
  * @throws IOException On errors reading the RTF fragment.
  * @throws DocumentException On errors adding to this RTF fragment.
  */
 public void ImportRtfFragment(Stream documentSource, RtfImportMappings mappings)
 {
     ImportRtfFragment(documentSource, mappings, null);
 }
 /**
 * Imports the mappings defined in the RtfImportMappings into the
 * RtfImportHeader of this RtfParser2.
 * 
 * @param importMappings 
 *       The RtfImportMappings to import.
 */
 private void HandleImportMappings(RtfImportMappings importMappings) {
     foreach (String fontNr in importMappings.GetFontMappings().Keys) {
         this.importMgr.ImportFont(fontNr, (String) importMappings.GetFontMappings()[fontNr]);
     }
     foreach (String colorNr in importMappings.GetColorMappings().Keys) {
         this.importMgr.ImportColor(colorNr, (Color) importMappings.GetColorMappings()[colorNr]);
     }
     foreach (String listNr in importMappings.GetListMappings().Keys) {
         this.importMgr.ImportList(listNr, (String)importMappings.GetListMappings()[listNr]);
     }
     foreach (String stylesheetListNr in importMappings.GetStylesheetListMappings().Keys) {
         this.importMgr.ImportStylesheetList(stylesheetListNr, (List) importMappings.GetStylesheetListMappings()[stylesheetListNr]);
     }
     
 }
 /**
 * Imports an RTF fragment.
 * 
 * @param readerIn 
 *       The Reader to read the RTF fragment from.
 * @param rtfDoc 
 *       The RTF document to add the RTF fragment to.
 * @param importMappings 
 *       The RtfImportMappings defining font and color mappings for the fragment.
 * @throws IOException 
 *       On I/O errors.
 */
 public void ImportRtfFragment(Stream readerIn, RtfDocument rtfDoc, RtfImportMappings importMappings) {
 //public void ImportRtfFragment2(Reader readerIn, RtfDocument rtfDoc, RtfImportMappings importMappings) throws IOException {
     if (readerIn == null || rtfDoc == null || importMappings==null) return;
     this.Init(TYPE_IMPORT_FRAGMENT, rtfDoc, readerIn, null, null);
     this.HandleImportMappings(importMappings);
     this.SetCurrentDestination(RtfDestinationMgr.DESTINATION_DOCUMENT);
     this.groupLevel = 1;
     SetParserState(RtfParser.PARSER_IN_DOCUMENT);
     startDate = DateTime.Now;
     startTime = startDate.Ticks / 10000L;
     this.Tokenise();
     endDate = DateTime.Now;
     endTime = endDate.Ticks / 10000L;
 }