Ejemplo n.º 1
0
        /* (non-Javadoc)
         * @see com.itextpdf.html2pdf.css.apply.ICssApplier#apply(com.itextpdf.html2pdf.attach.ProcessorContext, com.itextpdf.html2pdf.html.node.IStylesContainer, com.itextpdf.html2pdf.attach.ITagWorker)
         */
        public override void Apply(ProcessorContext context, IStylesContainer stylesContainer, ITagWorker tagWorker
                                   )
        {
            IDictionary <String, String> originalStyles = stylesContainer.GetStyles();
            IDictionary <String, String> styles         = new Dictionary <String, String>(originalStyles);

            // In general, if border color is not specified, it should take the value from color CSS property.
            // However, <hr> tag is an exception from this rule and color property does not affect the border color.
            // This is a workaround to solve the problem of color property being taken into account for <hr> tag.
            // Please note that this problem might as well be solved at BorderStyleApplierUtil.
            styles.JRemove(CssConstants.COLOR);
            stylesContainer.SetStyles(styles);
            base.Apply(context, stylesContainer, tagWorker);
            stylesContainer.SetStyles(originalStyles);
        }
Ejemplo n.º 2
0
            /* (non-Javadoc)
             * @see iText.Html2pdf.Css.Apply.Impl.BlockCssApplier#apply(iText.Html2pdf.Attach.ProcessorContext, iText.StyledXmlParser.Node.IStylesContainer, iText.Html2pdf.Attach.ITagWorker)
             */
            public override void Apply(ProcessorContext context, IStylesContainer stylesContainer, ITagWorker tagWorker)
            {
                IDictionary <String, String> cssStyles = stylesContainer.GetStyles();

                if (cssStyles.ContainsKey("kleur"))
                {
                    cssStyles.Add(CssConstants.COLOR, KLEUR[cssStyles["kleur"]]);
                    stylesContainer.SetStyles(cssStyles);
                }

                if (cssStyles.ContainsKey("achtergrond"))
                {
                    cssStyles.Add(CssConstants.BACKGROUND_COLOR, KLEUR[cssStyles["achtergrond"]]);
                    stylesContainer.SetStyles(cssStyles);
                }

                base.Apply(context, stylesContainer, tagWorker);
            }
        public override void Apply(ProcessorContext context, IStylesContainer stylesContainer, ITagWorker tagWorker)
        {
            IDictionary <string, string> cssStyles = stylesContainer.GetStyles();

            if (cssStyles.ContainsKey(CssConstants.COLOR))
            {
                string newColor = TransformColor(cssStyles[CssConstants.COLOR]);
                cssStyles[CssConstants.COLOR] = newColor;
                stylesContainer.SetStyles(cssStyles);
            }

            if (cssStyles.ContainsKey(CssConstants.BACKGROUND_COLOR))
            {
                string newColor = TransformColor(cssStyles[CssConstants.BACKGROUND_COLOR]);
                cssStyles[CssConstants.BACKGROUND_COLOR] = newColor;
                stylesContainer.SetStyles(cssStyles);
            }

            base.Apply(context, stylesContainer, tagWorker);
        }