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


C# HtmlPipelineContext.CharSet方法代码示例

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


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

示例1: Clone

        /**
         * Create a clone of this HtmlPipelineContext, the clone only contains the
         * initial values, not the internal values. Beware, the state of the current
         * Context is not copied to the clone. Only the configurational important
         * stuff like the LinkProvider (same object), ImageProvider (new
         * {@link AbstractImageProvider} with same ImageRootPath) ,
         * TagProcessorFactory (same object), acceptUnknown (primitive), charset
         * (Charset.forName to get a new charset), autobookmark (primitive) are
         * copied.
         */

        virtual public object Clone()
        {
            CssAppliers cloneCssApliers = this.cssAppliers.Clone();
            HtmlPipelineContext newCtx = new HtmlPipelineContext(cloneCssApliers);
            if (this.imageProvider != null)
            {
                newCtx.SetImageProvider(imageProvider);
            }
            if (null != this.charset)
            {
                newCtx.CharSet(Encoding.GetEncoding(this.charset.CodePage));
            }
            newCtx.SetPageSize(new Rectangle(this.pageSize)).SetLinkProvider(this.linkprovider)
                .SetRootTags(new List<String>(this.roottags)).AutoBookmark(this.autoBookmark)
                .SetTagFactory(this.tagFactory).SetAcceptUnknown(this.acceptUnknown);
            return newCtx;
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:28,代码来源:HtmlPipelineContext.cs

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


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