AddCssFile() public method

public AddCssFile ( String href, bool isPersistent ) : void
href String
isPersistent bool
return void
コード例 #1
0
 virtual public void SetUp() {
     LoggerFactory.GetInstance().SetLogger(new SysoLogger(3));
     files = new CssFilesImpl();
     StyleAttrCSSResolver resolver = new StyleAttrCSSResolver(files);
     string u = RESOURCES + "/css/style.css";
     resolver.AddCssFile(u.Replace("%20", " "), false); // fix url conversion of space (%20) for File
     Dictionary<String, String> attr = new Dictionary<String, String>();
     t = new Tag("body", attr);
 }
コード例 #2
0
ファイル: PdfService.cs プロジェクト: TomKaminski/ITAD2015
        private StyleAttrCSSResolver InitializeCssFiles(string[] cssPaths)
        {
            var cssFiles = new CssFilesImpl();
            cssFiles.Add(XMLWorkerHelper.GetInstance().GetDefaultCSS());

            var cssResolver = new StyleAttrCSSResolver(cssFiles);
            cssResolver.AddCss(@"body { padding: 2px 4px; }", "utf-8", true);

            foreach (var cssPath in cssPaths)
            {
                cssResolver.AddCssFile(cssPath, false);
            }

            return cssResolver;
        }
コード例 #3
0
        static protected void TransformHtml2Pdf(FileStream inputHtml, Document doc, PdfWriter pdfWriter) {
            CssFilesImpl cssFiles = new CssFilesImpl();
            cssFiles.Add(XMLWorkerHelper.GetInstance().GetDefaultCSS());
            StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);

            String Css1 =
                "https://specialtyonlinestg.cardinalhealth.com/CardinalHealthSpecialty/themes/html/SS_SPDCardinalHealth/css/globalStyles.css?version=RI_20121023";
            String Css2 =
                "https://specialtyonlinestg.cardinalhealth.com/CardinalHealthSpecialty/themes/html/SS_SPDCardinalHealth/css/SPDCSS/CAHPHReconciliationPortletView.css?version=AC_20120717";

            try {
                cssResolver.AddCssFile(Css1, true);
                cssResolver.AddCssFile(Css2, true);
            }
            catch (CssResolverException e) {
                // TODO Auto-generated catch block
            }

            HtmlPipelineContext htmlContext = new HtmlPipelineContext(new CssAppliersImpl(new XMLWorkerFontProvider()));
            htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
            htmlContext.SetPageSize(new Rectangle(doc.Left, doc.Bottom, doc.Right, doc.Top));

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


            XMLWorker worker = new XMLWorker(css, true);
            XMLParser parser = new XMLParser(worker, Encoding.UTF8);
            parser.Parse(inputHtml, Encoding.UTF8);
        }