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


C# HtmlPipelineContext.SetLinkProvider方法代码示例

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


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

示例1: 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

示例2: AddingALinkProvider

 virtual public void AddingALinkProvider() {
     Document doc = new Document(PageSize.A4);
     PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(TARGET + "columbus3.pdf", FileMode.Create));
     doc.Open();
     HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
     htmlContext.SetLinkProvider(new CustomLinkProvider()).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,代码行数:14,代码来源:XMLWorkerHTMLExample.cs


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