当前位置: 首页>>代码示例>>C#>>正文


C# XMLParser.Parse方法代码示例

本文整理汇总了C#中iTextSharp.tool.xml.parser.XMLParser.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# XMLParser.Parse方法的具体用法?C# XMLParser.Parse怎么用?C# XMLParser.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iTextSharp.tool.xml.parser.XMLParser的用法示例。


在下文中一共展示了XMLParser.Parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GeneratePdfFromView

        public byte[] GeneratePdfFromView(string viewString, string[] cssPaths, string fontPath)
        {
            using (var memoryStream = new MemoryStream())
            {
                var doc = new Document(PageSize.A4);
                var writer = PdfWriter.GetInstance(doc, memoryStream);

                doc.Open();

                var tagProcessors = InitializeTagProcessor();
                var cssResolver = InitializeCssFiles(cssPaths);

                var fontProvider = new CustomFontFactory(fontPath);

                var hpc = new HtmlPipelineContext(new CssAppliersImpl(fontProvider));
                hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(tagProcessors);

                var htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(doc, writer));
                var pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);

                var worker = new XMLWorker(pipeline, true);
                var xmlParser = new XMLParser(true, worker, Encoding.Unicode);
                xmlParser.Parse(new StringReader(viewString));

                doc.Close();
                return memoryStream.ToArray();
            }
        }
开发者ID:TomKaminski,项目名称:ITAD2015,代码行数:28,代码来源:PdfService.cs

示例2: TransformHtml2Pdf

        protected override void TransformHtml2Pdf() {
            Document doc = new Document(PageSize.A1.Rotate());
            PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(outPdf, FileMode.Create));
            doc.SetMargins(doc.LeftMargin - 10, doc.RightMargin - 10, doc.TopMargin, doc.BottomMargin);
            doc.Open();


            CssFilesImpl cssFiles = new CssFilesImpl();
            cssFiles.Add(
                XMLWorkerHelper.GetCSS(
                    File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + testName +
                                  Path.DirectorySeparatorChar + "complexDiv02_files" + Path.DirectorySeparatorChar +
                                  "minimum0.css")));
            cssFiles.Add(
                XMLWorkerHelper.GetCSS(
                    File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + testName +
                                  Path.DirectorySeparatorChar + "complexDiv02_files" + Path.DirectorySeparatorChar +
                                  "print000.css")));
            cssFiles.Add(XMLWorkerHelper.GetCSS(File.OpenRead(RESOURCES + @"\tool\xml\examples\" + "sampleTest.css")));
            StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
            HtmlPipelineContext hpc =
                new HtmlPipelineContext(
                    new CssAppliersImpl(new XMLWorkerFontProvider(RESOURCES + @"\tool\xml\examples\fonts")));
            hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(Tags.GetHtmlTagProcessorFactory());
            hpc.SetImageProvider(new SampleTestImageProvider());
            HtmlPipeline htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(doc, pdfWriter));
            IPipeline pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
            XMLWorker worker = new XMLWorker(pipeline, true);
            XMLParser p = new XMLParser(true, worker, Encoding.GetEncoding("UTF-8"));
            p.Parse(File.OpenRead(inputHtml), Encoding.GetEncoding("UTF-8"));
            doc.Close();
        }
开发者ID:smartleos,项目名称:itextsharp,代码行数:32,代码来源:ComplexDiv02Test.cs

示例3: MakePdf

        protected override void MakePdf(string outPdf) {
            Document doc = new Document(PageSize.A4.Rotate());
            PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(outPdf, FileMode.Create));
            doc.SetMargins(45, 45, 0, 100);
            doc.Open();


            CssFilesImpl cssFiles = new CssFilesImpl();
            cssFiles.Add(
                XMLWorkerHelper.GetCSS(
                    File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + Path.DirectorySeparatorChar + testName +
                                  Path.DirectorySeparatorChar + "complexDiv_files" + Path.DirectorySeparatorChar +
                                  "main.css")));
            cssFiles.Add(
                XMLWorkerHelper.GetCSS(
                    File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + Path.DirectorySeparatorChar + testName +
                                  Path.DirectorySeparatorChar + "complexDiv_files" + Path.DirectorySeparatorChar +
                                  "widget082.css")));
            StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
            HtmlPipelineContext hpc =
                new HtmlPipelineContext(
                    new CssAppliersImpl(new XMLWorkerFontProvider(RESOURCES + @"\tool\xml\examples\fonts")));
            hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(Tags.GetHtmlTagProcessorFactory());
            hpc.SetImageProvider(new SampleTestImageProvider());
            hpc.SetPageSize(doc.PageSize);
            HtmlPipeline htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(doc, pdfWriter));
            IPipeline pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
            XMLWorker worker = new XMLWorker(pipeline, true);
            XMLParser p = new XMLParser(true, worker, Encoding.GetEncoding("UTF-8"));
            p.Parse(File.OpenRead(inputHtml), Encoding.GetEncoding("UTF-8"));
            doc.Close();
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:32,代码来源:ComplexDivPagination01Test.cs

示例4: HtmlToPdf

        public void HtmlToPdf(string htmlFile, string pdfFile, string htmlImageDirectory)
        {
            using (FileStream pdfStream = new FileStream(pdfFile, FileMode.OpenOrCreate))
            {
                Document doc = new Document();
                PdfWriter writer = PdfWriter.GetInstance(doc, pdfStream);
                doc.Open();

                //TODO: apply external css
                ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(true);

                //HTML
                HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
                htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
                htmlContext.SetImageProvider(new ImageProvider(htmlImageDirectory));
                htmlContext.SetLinkProvider(new LinkProvider("/"));

                //pipelines
                PdfWriterPipeline pdf = new PdfWriterPipeline(doc, writer);
                HtmlPipeline html = new HtmlPipeline(htmlContext, pdf);
                CssResolverPipeline css = new CssResolverPipeline(cssResolver, html);

                XMLWorker worker = new XMLWorker(css, true);
                XMLParser p = new XMLParser(true, worker, Encoding.UTF8);

                using (TextReader reader = File.OpenText(htmlFile))
                {
                    p.Parse(reader);
                }

                doc.Close();
            }
        }
开发者ID:markglibres,项目名称:cad.documents,代码行数:33,代码来源:iTextSharperPdfProcessor.cs

示例5: ParseXfaOnlyXML

 virtual public void ParseXfaOnlyXML() {
     StreamReader bis = File.OpenText(RESOURCE_TEST_PATH + SNIPPETS + TEST + "snippet.html");
     Document doc = new Document(PageSize.A4);
     float margin = utils.ParseRelativeValue("10%", PageSize.A4.Width);
     doc.SetMargins(margin, margin, margin, margin);
     PdfWriter writer = null;
     try {
         writer = PdfWriter.GetInstance(doc, new FileStream(
             TARGET + TEST + "_charset.pdf", FileMode.Create));
     }
     catch (DocumentException e) {
         Console.WriteLine(e);
     }
     CssFilesImpl cssFiles = new CssFilesImpl();
     cssFiles.Add(XMLWorkerHelper.GetInstance().GetDefaultCSS());
     StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
     HtmlPipelineContext hpc = new HtmlPipelineContext(null);
     hpc.SetAcceptUnknown(true)
         .AutoBookmark(true)
         .SetTagFactory(Tags.GetHtmlTagProcessorFactory())
         .CharSet(Encoding.GetEncoding("ISO-8859-1"));
     IPipeline pipeline = new CssResolverPipeline(cssResolver,
         new HtmlPipeline(hpc, new PdfWriterPipeline(doc, writer)));
     XMLWorker worker = new XMLWorker(pipeline, true);
     doc.Open();
     XMLParser p = new XMLParser(true, worker);
     p.Parse(bis);
     doc.Close();
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:29,代码来源:SpecialCharInPDFTest.cs

示例6: Parse

        public virtual void Parse(Stream stream, string xHtml)
        {
            xHtml = XhtmlCleaner != null
                ? XhtmlCleaner(xHtml)
                : XhtmlHelper.CloseSimpleTags(xHtml);
            InitParser();

            using (var stringReader = new StringReader(xHtml))
            {
                using (Document document = new Document())
                {
                    PdfWriter writer = PdfWriter.GetInstance(document, stream);
                    document.Open();

                    HtmlPipelineContext
                        .SetTagFactory(TagProcessorFactory)
                        .SetLinkProvider(LinkProvider)
                        .SetImageProvider(ImageProvider)
                    ;
                    var pdfWriterPipeline = new PdfWriterPipeline(document, writer);
                    var htmlPipeline = new HtmlPipeline(HtmlPipelineContext, pdfWriterPipeline);
                    var cssResolverPipeline = new CssResolverPipeline(CssResolver, htmlPipeline);

                    XMLWorker worker = new XMLWorker(cssResolverPipeline, true);
                    XMLParser parser = new XMLParser(worker);
                    parser.Parse(stringReader);
                }
            }
        }
开发者ID:kuujinbo,项目名称:StackOverflow.iTextSharp.MVC,代码行数:29,代码来源:SimpleParser.cs

示例7: StickyComment

 virtual public void StickyComment() {
     String html = "<p><!--stickycomment-->sometext  moretext</p>";
     String expected = "<p><!--stickycomment-->sometext  moretext</p>";
     XMLParser p = new XMLParser(false, Encoding.Default);
     StringBuilder b = Init(html, p);
     p.Parse(new MemoryStream(Encoding.Default.GetBytes(html)));
     Assert.AreEqual(expected, b.ToString());
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:8,代码来源:ParserTest.cs

示例8: SpecialTag

 virtual public void SpecialTag() {
     String html = "<p><?formServer acrobat8.1dynamic defaultPDFRenderFormat?>ohoh</p>";
     XMLParser p = new XMLParser(false, Encoding.GetEncoding("UTF-8"));
     StringBuilder b = Init(html, p);
     p.Parse(new MemoryStream(Encoding.Default.GetBytes(html)));
     String str = b.ToString();
     Assert.IsTrue(str.Contains("acrobat8.1dynamic") && str.Contains("defaultPDFRenderFormat"));
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:8,代码来源:ParserTest.cs

示例9: SetupDefaultProcessingYourself

 virtual public void SetupDefaultProcessingYourself() {
     Document doc = new Document(PageSize.A4);
     PdfWriter writer = PdfWriter.GetInstance(doc,
         new FileStream(TARGET + "columbus2.pdf", FileMode.Create));
     doc.Open();
     HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
     htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
     ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(true);
     IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext,
         new PdfWriterPipeline(doc, writer)));
     XMLWorker worker = new XMLWorker(pipeline, true);
     XMLParser p = new XMLParser(worker);
     p.Parse(File.OpenRead(RESOURCES + @"\examples\columbus.html"));
     doc.Close();
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:15,代码来源:XMLWorkerHTMLExample.cs

示例10: TransformHtml2Pdf

        protected override void TransformHtml2Pdf(Document doc, PdfWriter pdfWriter, IImageProvider imageProvider,
            IFontProvider fontProvider, Stream cssFile) {
            ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(true);

            HtmlPipelineContext hpc;

            if (fontProvider != null)
                hpc = new HtmlPipelineContext(new CssAppliersImpl(fontProvider));
            else
                hpc = new HtmlPipelineContext(null);

            hpc.SetImageProvider(imageProvider);
            hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(Tags.GetHtmlTagProcessorFactory());
            HtmlPipeline htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(doc, pdfWriter));
            IPipeline pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
            XMLWorker worker = new XMLWorker(pipeline, true);
            XMLParser xmlParse = new XMLParser(true, worker, Encoding.UTF8);
            xmlParse.Parse(new FileStream(inputHtml, FileMode.Open), Encoding.UTF8);
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:19,代码来源:PageOverflow01Test.cs

示例11: MakePdf

        protected override void MakePdf(string outPdf) {
            Document doc = new Document(PageSize.A3.Rotate());

            PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(outPdf, FileMode.Create));
            pdfWriter.CreateXmpMetadata();

            doc.SetMargins(200, 200, 0, 0);
            doc.Open();


            CssFilesImpl cssFiles = new CssFilesImpl();
            cssFiles.Add(
                XMLWorkerHelper.GetCSS(
                    File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + Path.DirectorySeparatorChar + testName +
                                  Path.DirectorySeparatorChar + "complexDiv_files" + Path.DirectorySeparatorChar +
                                  "main.css")));
            cssFiles.Add(
                XMLWorkerHelper.GetCSS(
                    File.OpenRead(RESOURCES + Path.DirectorySeparatorChar + testPath + Path.DirectorySeparatorChar + testName +
                                  Path.DirectorySeparatorChar + "complexDiv_files" + Path.DirectorySeparatorChar +
                                  "widget082.css")));
            StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
            HtmlPipelineContext hpc =
                new HtmlPipelineContext(
                    new CssAppliersImpl(new XMLWorkerFontProvider(RESOURCES + @"\tool\xml\examples\fonts")));
            hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(Tags.GetHtmlTagProcessorFactory());
            hpc.SetImageProvider(new SampleTestImageProvider());
            hpc.SetPageSize(doc.PageSize);
            HtmlPipeline htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(doc, pdfWriter));
            IPipeline pipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
            XMLWorker worker = new XMLWorker(pipeline, true);
            XMLParser p = new XMLParser(true, worker, Encoding.GetEncoding("UTF-8"));
            p.Parse(File.OpenRead(inputHtml), Encoding.GetEncoding("UTF-8"));
            //ICC_Profile icc = ICC_Profile.getInstance(ComplexDiv01Test.class.getResourceAsStream("sRGB Color Space Profile.icm"));
            //pdfWriter.setOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
            doc.Close();
        }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:37,代码来源:ComplexDiv01Test.cs

示例12: ParseXHtml

 /**
  * @param d the ElementHandler
  * @param inp the Stream
  * @throws IOException if something went seriously wrong with IO.
  */
 public void ParseXHtml(IElementHandler d, Stream inp, Encoding charset) {
     CssFilesImpl cssFiles = new CssFilesImpl();
     cssFiles.Add(GetDefaultCSS());
     StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);
     HtmlPipelineContext hpc = new HtmlPipelineContext(null);
     hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(GetDefaultTagProcessorFactory());
     IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(hpc, new ElementHandlerPipeline(d,
             null)));
     XMLWorker worker = new XMLWorker(pipeline, true);
     XMLParser p = new XMLParser(true, worker, charset);
     if (charset != null) {
         p.Parse(inp, charset);
     } else {
         p.Parse(inp);
     }
 }
开发者ID:smartleos,项目名称:itextsharp,代码行数:21,代码来源:XMLWorkerHelper.cs

示例13: iTextSharp

        private void iTextSharp(string html)
        {
            System.Web.HttpContext.Current.Response.ContentType = "application/pdf";
            System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=BookingDetails.pdf");
            System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            Document pdfDoc = new Document(new Rectangle(922, 1296), 7f, 7f, 7f, 0f);

            PdfWriter writer = PdfWriter.GetInstance(pdfDoc, System.Web.HttpContext.Current.Response.OutputStream);
            pdfDoc.Open();

            HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
            htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());

            ICssFile cfile = new CssFileImpl();
            ICSSResolver cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(false);
            cssResolver.AddCssFile(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + @"App_Data\PDF.all.min.css", true);

            //Pipeline
            IPipeline pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new PdfWriterPipeline(pdfDoc, writer)));
            //XMLWorker
            XMLWorker worker = new XMLWorker(pipeline, true);
            XMLParser parser = new XMLParser();
            parser.AddListener(worker);
            using (TextReader sr = new StringReader(html))
            {
                parser.Parse(sr);
            }

            parser.Flush();
            pdfDoc.Close();

            System.Web.HttpContext.Current.Response.Write(pdfDoc);
            System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
开发者ID:BoccaDamian,项目名称:bubis,代码行数:35,代码来源:ucExportToPDF.ascx.cs

示例14: SpecialChars

        virtual public void SpecialChars() {
            list = new List<String>();
            XMLParser p = new XMLParser(false, new CustomXMLParserListener());
            p.Parse(File.OpenRead(RESOURCES + "parser.xml"), Encoding.GetEncoding("UTF-8"));
//		org.junit.Assert.assertEquals(new String("e\u00e9\u00e8\u00e7\u00e0\u00f5".getBytes("UTF-8"), "UTF-8"), list.get(0));
//		org.junit.Assert.assertEquals(new String("e\u00e9\u00e8\u00e7\u00e0\u00f5".getBytes("UTF-8"), "UTF-8"), list.get(1));
            Assert.AreEqual("e\u00e9\u00e8\u00e7\u00e0\u00f5", list[0]);
            Assert.AreEqual("e\u00e9\u00e8\u00e7\u00e0\u00f5", list[1]);
        }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:9,代码来源:ParserTest.cs

示例15: GeneratePdf

        public static void GeneratePdf(IList<SqlPdfFormat> data, 
            string pdfFullFileName, string cssFullFileName)
        {
            data.OrderBy(x => x.SoldDate);
            DateTime oldDate = data[0].SoldDate;
            StringBuilder sb = new StringBuilder();
            decimal subSum = 0;
            decimal totalSum = 0;
           
            sb.Append("<table>");
            sb.Append("<tr>");
            sb.Append("<th colspan=\"5\" class=\"title\">Aggregated Sales Report </th>");
            sb.Append("</tr>");

            sb.Append("<tr class=\"grayBack\" >");
            sb.AppendFormat("<th colspan=\"5\" class=\"date\">Date: {0}</th>", oldDate.ToShortDateString());
            sb.Append("</tr>");
            sb.Append("<tr class=\"grayBack\" >");
            sb.Append("<th  class=\"th\">Product</th>");
            sb.Append("<th  class=\"th\">Quantity</th>");
            sb.Append("<th  class=\"th\">Unit Price</th>");
            sb.Append("<th  class=\"th\">Location</th>");
            sb.Append("<th  class=\"th\">Sum</th>");
            sb.Append("</tr>");

            for (int i = 0; i < data.Count; i++)
            {
                if (data[i].SoldDate > oldDate)
                {
                    sb.Append("<tr>");
                    sb.AppendFormat("<td colspan=\"4\" class=\"sum\">Total sum for {0}:&nbsp;</td>",
                        oldDate.ToShortDateString());
                    sb.AppendFormat("<td class=\"bold\">{0}</td>", subSum);
                    sb.Append("</tr>");

                    oldDate = data[i].SoldDate;
                    totalSum += subSum;
                    subSum = 0;

                    sb.Append("<tr class=\"grayBack\">");
                    sb.AppendFormat("<th colspan=\"5\" class=\"date\">Date: {0}</th>", 
                        oldDate.ToShortDateString());
                    sb.Append("</tr>");
                    sb.Append("<tr class=\"grayBack\">");
                    sb.Append("<th  class=\"th\">Product</th>");
                    sb.Append("<th  class=\"th\">Quantity</th>");
                    sb.Append("<th  class=\"th\">Unit Price</th>");
                    sb.Append("<th  class=\"th\">Location</th>");
                    sb.Append("<th  class=\"th\">Sum</th>");
                    sb.Append("</tr>");
                }

                subSum += data[i].Sum;

                sb.Append("<tr>");
                sb.AppendFormat("<td>{0}</td>", data[i].ProductName);
                sb.AppendFormat("<td>{0}</td>", data[i].Quantity + " " + data[i].Measure);
                sb.AppendFormat("<td>{0}</td>", data[i].UnitPrice);
                sb.AppendFormat("<td>{0}</td>", data[i].SupermarketName);
                sb.AppendFormat("<td>{0}</td>", data[i].Sum);
                sb.Append("</tr>");
            }

            sb.Append("<tr>");
            sb.AppendFormat("<td colspan=\"4\" class=\"sum\">Total sum for {0}:&nbsp;</td>",
                oldDate.ToShortDateString());
            sb.AppendFormat("<td class=\"bold\">{0}</td>", subSum);
            sb.Append("</tr>");

            totalSum += subSum;

            sb.Append("<tr>");
            sb.Append("<td colspan=\"4\" class=\"sum\">Grand Total:&nbsp;</td>");
            sb.AppendFormat("<td class=\"bold\">{0}</td>", totalSum);
            sb.Append("</tr>");
            sb.Append("</table>");
            
            using (Document document = new Document())
            {
                PdfWriter writer = PdfWriter.GetInstance(document,
                    new FileStream(pdfFullFileName, FileMode.Create));
                document.Open();

                HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
                htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());

                ICSSResolver cssResolver =
                    XMLWorkerHelper.GetInstance().GetDefaultCssResolver(true);
                //change this to your CCS file location
                cssResolver.AddCssFile(cssFullFileName, true);
                IPipeline pipeline =
                    new CssResolverPipeline(cssResolver,
                        new HtmlPipeline(htmlContext,
                            new PdfWriterPipeline(document, writer)));

                XMLWorker worker = new XMLWorker(pipeline, true);
                XMLParser p = new XMLParser(worker);
                //p.Parse((TextReader)File.OpenText(@"G:\Template.html"));
                p.Parse(new StringReader(sb.ToString()));
            }
//.........这里部分代码省略.........
开发者ID:niki-funky,项目名称:Telerik_Academy,代码行数:101,代码来源:PdfGenerator.cs


注:本文中的iTextSharp.tool.xml.parser.XMLParser.Parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。