當前位置: 首頁>>代碼示例>>C#>>正文


C# XMLParser.AddListener方法代碼示例

本文整理匯總了C#中iTextSharp.tool.xml.parser.XMLParser.AddListener方法的典型用法代碼示例。如果您正苦於以下問題:C# XMLParser.AddListener方法的具體用法?C# XMLParser.AddListener怎麽用?C# XMLParser.AddListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.tool.xml.parser.XMLParser的用法示例。


在下文中一共展示了XMLParser.AddListener方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ParseXHtml

 /**
  * 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 inp the reader
  * @throws IOException thrown when something went wrong with the IO
  */
 public void ParseXHtml(PdfWriter writer, Document doc, TextReader inp) {
     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 PdfWriterPipeline(doc,
             writer)));
     XMLWorker worker = new XMLWorker(pipeline, true);
     XMLParser p = new XMLParser();
     p.AddListener(worker);
     p.Parse(inp);
 }
開發者ID:smartleos,項目名稱:itextsharp,代碼行數:23,代碼來源:XMLWorkerHelper.cs

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

示例3: processHtml

        private void processHtml(IElementHandler elementsHandler)
        {
            var cssResolver = new StyleAttrCSSResolver();

            if (CssFilesPath != null && CssFilesPath.Any())
            {
                foreach (var cssFile in CssFilesPath)
                {
                    cssResolver.AddCss(XmlWorkerUtils.GetCssFile(cssFile));
                }
            }

            if (!string.IsNullOrEmpty(InlineCss))
            {
                cssResolver.AddCss(InlineCss, "utf-8", true);
            }

            var htmlContext = new HtmlPipelineContext(new CssAppliersImpl(new UnicodeFontProvider(DefaultFont)));
            if (!string.IsNullOrEmpty(ImagesPath))
            {
                htmlContext.SetImageProvider(new ImageProvider { ImagesPath = ImagesPath });
            }
            htmlContext.CharSet(Encoding.UTF8);

            var tagsProcessorFactory = (DefaultTagProcessorFactory)Tags.GetHtmlTagProcessorFactory();
            if (PdfElement != null)
            {
                tagsProcessorFactory.AddProcessor("totalpagesnumber", new TotalPagesNumberXmlWorkerProcessor(PdfElement));
            }

            htmlContext.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(tagsProcessorFactory);
            var pipeline = new CssResolverPipeline(cssResolver,
                                                   new HtmlPipeline(htmlContext, new ElementHandlerPipeline(elementsHandler, null)));
            var worker = new XMLWorker(pipeline, parseHtml: true);
            var parser = new XMLParser();
            parser.AddListener(worker);
            parser.Parse(new StringReader(Html));
        }
開發者ID:VahidN,項目名稱:PdfReport,代碼行數:38,代碼來源:XmlWorkerHelper.cs

示例4: Init

        /**
	 * @param html
	 * @param p
	 * @return
	 */

        private StringBuilder Init(String html, XMLParser p) {
            writer = new StringBuilder(html.Length);
            p.AddListener(new ParserListenerWriter(new CustomAppender(), false));
            return writer;
        }
開發者ID:jagruti23,項目名稱:itextsharp,代碼行數:11,代碼來源:ParserTest.cs


注:本文中的iTextSharp.tool.xml.parser.XMLParser.AddListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。