diff --git a/src/Html2OpenXml/Expressions/BlockElementExpression.cs b/src/Html2OpenXml/Expressions/BlockElementExpression.cs index aad5a06..7ae7026 100644 --- a/src/Html2OpenXml/Expressions/BlockElementExpression.cs +++ b/src/Html2OpenXml/Expressions/BlockElementExpression.cs @@ -87,42 +87,6 @@ public override IEnumerable Interpret (ParsingContext context) return [CreateFrame(childElements)]; } - /// - /// Group all the paragraph inside a framed table. - /// - private Table CreateFrame(IEnumerable childElements) - { - TableCell cell; - TableProperties tableProperties; - Table framedTable = new( - tableProperties = new TableProperties { - TableWidth = new() { Type = TableWidthUnitValues.Auto, Width = "0" } // 100% - }, - new TableGrid( - new GridColumn() { Width = "5610" }), - new TableRow( - cell = new TableCell(childElements) - ) - ); - - if (!styleBorder.IsEmpty) - { - tableProperties.TableBorders = new TableBorders { - LeftBorder = Converter.ToBorder(styleBorder.Left), - RightBorder = Converter.ToBorder(styleBorder.Right), - TopBorder = Converter.ToBorder(styleBorder.Top), - BottomBorder = Converter.ToBorder(styleBorder.Bottom) - }; - } - - if (runProperties.Shading != null) - { - cell.TableCellProperties = new() { Shading = (Shading?) runProperties.Shading.Clone() }; - } - - return framedTable; - } - protected override IEnumerable Interpret ( ParsingContext context, IEnumerable childNodes) { @@ -216,6 +180,7 @@ protected override void ComposeStyles (ParsingContext context) if (!styleBorder.IsEmpty) { renderAsFramed = true; + runProperties.Border = null; } foreach (string className in node.ClassList) @@ -394,6 +359,43 @@ private static Paragraph CreateParagraph(ParsingContext context, IList + /// Group all the paragraph inside a framed table. + /// + private Table CreateFrame(IEnumerable childElements) + { + TableCell cell; + TableProperties tableProperties; + Table framedTable = new( + tableProperties = new TableProperties { + TableWidth = new() { Type = TableWidthUnitValues.Pct, Width = "5000" } // 100% + }, + new TableGrid( + new GridColumn() { Width = "9442" }), + new TableRow( + cell = new TableCell(childElements) + ) + ); + + if (!styleBorder.IsEmpty) + { + tableProperties.TableBorders = new TableBorders { + LeftBorder = Converter.ToBorder(styleBorder.Left), + RightBorder = Converter.ToBorder(styleBorder.Right), + TopBorder = Converter.ToBorder(styleBorder.Top), + BottomBorder = Converter.ToBorder(styleBorder.Bottom) + }; + } + + if (runProperties.Shading != null) + { + cell.TableCellProperties = new() { Shading = (Shading?) runProperties.Shading.Clone() }; + } + + return framedTable; + } + /// /// Resolve the next available (they must be unique). ///