當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。