Exemple #1
0
        /**
         * Parses the xml data. This method configures the XMLWorker to parse
         * (X)HTML/CSS and accept unknown tags. Writes the output in the given
         * PdfWriter with the given document.
         *
         * @param writer the PdfWriter
         * @param doc the Document
         * @param in the reader
         * @throws IOException thrown when something went wrong with the IO
         */
        public PdfTemplate ParseToTemplate(PdfContentByte cb, TextReader input)
        {
            CssFilesImpl cssFiles = new CssFilesImpl();

            cssFiles.Add(GetDefaultCSS());
            ICSSResolver       cssResolver = new StyleAttrSvgCSSResolver(cssFiles);
            SvgPipelineContext hpc         = new SvgPipelineContext();

            hpc.SetTagFactory(GetDefaultTagProcessorFactory());
            PdfTemplatePipeline templatePipeline = new PdfTemplatePipeline(cb);
            IPipeline           pipeline         = new CssResolverPipeline(cssResolver, new SvgPipeline(hpc, templatePipeline));
            XMLWorker           worker           = new XMLWorker(pipeline, true);
            XMLParser           p = new XMLParser();

            p.AddListener(worker);
            p.Parse(input);
            return(templatePipeline.GetTemplate());
        }
Exemple #2
0
 /**
  * Parses the xml data. This method configures the XMLWorker to parse
  * (X)HTML/CSS and accept unknown tags. Writes the output in the given
  * PdfWriter with the given document.
  *
  * @param writer the PdfWriter
  * @param doc the Document
  * @param in the reader
  * @throws IOException thrown when something went wrong with the IO
  */
 public PdfTemplate ParseToTemplate(PdfContentByte cb, TextReader input)
 {
     CssFilesImpl cssFiles = new CssFilesImpl();
     cssFiles.Add(GetDefaultCSS());
     ICSSResolver cssResolver = new StyleAttrSvgCSSResolver(cssFiles);
     SvgPipelineContext hpc = new SvgPipelineContext();
     hpc.SetTagFactory(GetDefaultTagProcessorFactory());
     PdfTemplatePipeline templatePipeline = new PdfTemplatePipeline(cb);
     IPipeline pipeline = new CssResolverPipeline(cssResolver, new SvgPipeline(hpc, templatePipeline));
     XMLWorker worker = new XMLWorker(pipeline, true);
     XMLParser p = new XMLParser();
     p.AddListener(worker);
     p.Parse(input);
     return templatePipeline.GetTemplate();
 }