diff --git a/QuestPDF.Examples/TableExamples.cs b/QuestPDF.Examples/TableExamples.cs index 6c9b190..e622e41 100644 --- a/QuestPDF.Examples/TableExamples.cs +++ b/QuestPDF.Examples/TableExamples.cs @@ -21,13 +21,13 @@ namespace QuestPDF.Examples { RenderingTest .Create() - .ProduceImages() + .ProducePdf() .PageSize(PageSizes.A4) .MaxPages(10_000) .EnableCaching() .EnableDebugging(false) .ShowResults() - .Render(container => GeneratePerformanceStructure(container, 10)); + .Render(container => GeneratePerformanceStructure(container, 1000)); } public static void GeneratePerformanceStructure(IContainer container, int repeats) diff --git a/QuestPDF/Elements/Table/Table.cs b/QuestPDF/Elements/Table/Table.cs index 6fca6e5..26f4f64 100644 --- a/QuestPDF/Elements/Table/Table.cs +++ b/QuestPDF/Elements/Table/Table.cs @@ -116,7 +116,7 @@ namespace QuestPDF.Elements.Table var commands = GetRenderingCommands(); var tableHeight = commands.Max(cell => cell.Offset.Y + cell.Size.Height); - AdjustCellSizes(tableHeight, commands); + AdjustCellSizes(commands); AdjustLastCellSizes(tableHeight, commands); return commands; @@ -207,15 +207,17 @@ namespace QuestPDF.Elements.Table // corner sase: if two cells end up on the same row (a.Row + a.RowSpan = b.Row + b.RowSpan), // bottom edges of their bounding boxes should be at the same level - static void AdjustCellSizes(float tableHeight, ICollection commands) + static void AdjustCellSizes(ICollection commands) { - // TODO: this is wrong - // should use GroupBy(x => x.Row + x.RowSpan) and determine target height - foreach (var command in commands) - { - var height = tableHeight - command.Offset.Y; - command.Size = new Size(command.Size.Width, height); - } + commands + .GroupBy(x => x.Cell.Row + x.Cell.RowSpan) + .ToList() + .ForEach(group => + { + var groupCells = group.ToList(); + var bottomBorderOffset = groupCells.Max(x => x.Offset.Y + x.Size.Height); + groupCells.ForEach(x => x.Size = new Size(x.Size.Width, bottomBorderOffset - x.Offset.Y)); + }); } // corner sase: all cells, that are last ones in their respective columns, should take all remaining space diff --git a/QuestPDF/QuestPDF.csproj b/QuestPDF/QuestPDF.csproj index de5c1cb..cf89f70 100644 --- a/QuestPDF/QuestPDF.csproj +++ b/QuestPDF/QuestPDF.csproj @@ -4,7 +4,7 @@ MarcinZiabek CodeFlint QuestPDF - 2022.1.0-beta0 + 2022.1.0-beta1 QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API. $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt")) 9