|
| 1 | +using System; |
| 2 | +using iText.Html2pdf.Attach; |
| 3 | +using iText.Html2pdf.Css; |
| 4 | +using iText.StyledXmlParser.Css; |
| 5 | +using iText.StyledXmlParser.Css.Page; |
| 6 | + |
| 7 | +namespace iText.Html2pdf.Attach.Impl.Layout { |
| 8 | + public class HeightDimensionContainer : DimensionContainer { |
| 9 | + internal HeightDimensionContainer(CssContextNode pmbcNode, float width, float maxHeight, ProcessorContext |
| 10 | + context) { |
| 11 | + String height = pmbcNode.GetStyles().Get(CssConstants.HEIGHT); |
| 12 | + if (height != null && !height.Equals("auto")) { |
| 13 | + dimension = ParseDimension(pmbcNode, height, maxHeight); |
| 14 | + } |
| 15 | + minDimension = GetMinHeight(pmbcNode, maxHeight); |
| 16 | + maxDimension = GetMaxHeight(pmbcNode, maxHeight); |
| 17 | + minContentDimension = PageContextProcessor.GetMinContentHeight((PageMarginBoxContextNode)pmbcNode, width, |
| 18 | + maxHeight, context); |
| 19 | + maxContentDimension = PageContextProcessor.GetMaxContentHeight((PageMarginBoxContextNode)pmbcNode, width, |
| 20 | + maxHeight, context); |
| 21 | + } |
| 22 | + |
| 23 | + internal virtual float GetMinHeight(CssContextNode node, float maxAvailableHeight) { |
| 24 | + String content = node.GetStyles().Get(CssConstants.MIN_HEIGHT); |
| 25 | + if (content == null) { |
| 26 | + return 0; |
| 27 | + } |
| 28 | + content = content.ToLowerInvariant().Trim(); |
| 29 | + if (content.Equals("inherit")) { |
| 30 | + if (node.ParentNode() is CssContextNode) { |
| 31 | + return GetMinHeight((CssContextNode)node.ParentNode(), maxAvailableHeight); |
| 32 | + } |
| 33 | + return 0; |
| 34 | + } |
| 35 | + return ParseDimension(node, content, maxAvailableHeight); |
| 36 | + } |
| 37 | + |
| 38 | + internal virtual float GetMaxHeight(CssContextNode node, float maxAvailableHeight) { |
| 39 | + String content = node.GetStyles().Get(CssConstants.MAX_HEIGHT); |
| 40 | + if (content == null) { |
| 41 | + return float.MaxValue; |
| 42 | + } |
| 43 | + content = content.ToLowerInvariant().Trim(); |
| 44 | + if (content.Equals("inherit")) { |
| 45 | + if (node.ParentNode() is CssContextNode) { |
| 46 | + return GetMaxHeight((CssContextNode)node.ParentNode(), maxAvailableHeight); |
| 47 | + } |
| 48 | + return float.MaxValue; |
| 49 | + } |
| 50 | + float dim = ParseDimension(node, content, maxAvailableHeight); |
| 51 | + if (dim == 0) { |
| 52 | + return float.MaxValue; |
| 53 | + } |
| 54 | + return dim; |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments