/* (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 virtual void Apply(ProcessorContext context, IStylesContainer stylesContainer, ITagWorker tagWorker ) { IDictionary <String, String> cssProps = stylesContainer.GetStyles(); IPropertyContainer container = tagWorker.GetElementResult(); if (container != null) { WidthHeightApplierUtil.ApplyWidthHeight(cssProps, context, container); BackgroundApplierUtil.ApplyBackground(cssProps, context, container); MarginApplierUtil.ApplyMargins(cssProps, context, container); PaddingApplierUtil.ApplyPaddings(cssProps, context, container); FontStyleApplierUtil.ApplyFontStyles(cssProps, context, stylesContainer, container); BorderStyleApplierUtil.ApplyBorders(cssProps, context, container); HyphenationApplierUtil.ApplyHyphenation(cssProps, context, stylesContainer, container); FloatApplierUtil.ApplyFloating(cssProps, context, container); PositionApplierUtil.ApplyPosition(cssProps, context, container); OpacityApplierUtil.ApplyOpacity(cssProps, context, container); PageBreakApplierUtil.ApplyPageBreakProperties(cssProps, context, container); OverflowApplierUtil.ApplyOverflow(cssProps, container); TransformationApplierUtil.ApplyTransformation(cssProps, context, container); OutlineApplierUtil.ApplyOutlines(cssProps, context, container); OrphansWidowsApplierUtil.ApplyOrphansAndWidows(cssProps, container); } }
/* (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 virtual void Apply(ProcessorContext context, IStylesContainer stylesContainer, ITagWorker tagWorker ) { SpanTagWorker spanTagWorker = (SpanTagWorker)tagWorker; IDictionary <String, String> cssStyles = stylesContainer.GetStyles(); foreach (IPropertyContainer child in spanTagWorker.GetOwnLeafElements()) { // Workaround for form fields so that SpanTagCssApplier does not apply its font-size to the child. // Form fields have their own CSS applier // TODO remove when form fields are not leaf elements anymore if (!(child is IFormField)) { ApplyChildElementStyles(child, cssStyles, context, stylesContainer); } } VerticalAlignmentApplierUtil.ApplyVerticalAlignmentForInlines(cssStyles, context, stylesContainer, spanTagWorker .GetAllElements()); if (cssStyles.ContainsKey(CssConstants.OPACITY)) { foreach (IPropertyContainer elem in spanTagWorker.GetAllElements()) { if (elem is Text && !elem.HasProperty(Property.OPACITY)) { OpacityApplierUtil.ApplyOpacity(cssStyles, context, elem); } } } // TODO as for now spans are flattened, let's at least make kids of floating spans floating too String floatVal = cssStyles.Get(CssConstants.FLOAT); if (floatVal != null && !CssConstants.NONE.Equals(floatVal)) { foreach (IPropertyContainer elem in spanTagWorker.GetAllElements()) { FloatPropertyValue?kidFloatVal = elem.GetProperty <FloatPropertyValue?>(Property.FLOAT); if (kidFloatVal == null || FloatPropertyValue.NONE.Equals(kidFloatVal)) { FloatApplierUtil.ApplyFloating(cssStyles, context, elem); } } } if (spanTagWorker.GetAllElements() != null) { foreach (IPropertyContainer child in spanTagWorker.GetAllElements()) { FloatPropertyValue?kidFloatVal = child.GetProperty <FloatPropertyValue?>(Property.FLOAT); if (child is Text && !child.HasOwnProperty(Property.BACKGROUND) && (kidFloatVal == null || FloatPropertyValue .NONE.Equals(kidFloatVal))) { BackgroundApplierUtil.ApplyBackground(cssStyles, context, child); } } } }
/// <summary>Applies styles to child elements.</summary> /// <param name="element">the element</param> /// <param name="css">the CSS mapping</param> /// <param name="context">the processor context</param> /// <param name="stylesContainer">the styles container</param> protected internal virtual void ApplyChildElementStyles(IPropertyContainer element, IDictionary <String, String > css, ProcessorContext context, IStylesContainer stylesContainer) { FontStyleApplierUtil.ApplyFontStyles(css, context, stylesContainer, element); BackgroundApplierUtil.ApplyBackground(css, context, element); //TODO: Border-applying currently doesn't work in html way for spans inside other spans. BorderStyleApplierUtil.ApplyBorders(css, context, element); OutlineApplierUtil.ApplyOutlines(css, context, element); HyphenationApplierUtil.ApplyHyphenation(css, context, stylesContainer, element); //TODO: Margins-applying currently doesn't work in html way for spans inside other spans. (see SpanTest#spanTest07) MarginApplierUtil.ApplyMargins(css, context, element); PositionApplierUtil.ApplyPosition(css, context, element); FloatApplierUtil.ApplyFloating(css, context, element); PaddingApplierUtil.ApplyPaddings(css, context, element); }