Hello,
we recently noticed that tables do not always behave correctly on page breaks.
Sometimes parts of the content that should be on the next page are rendered over the page’s bottom margin (and sometimes even out of the page bounds) and there’s a blank space on the next page where content should have been.
Sometimes there’s an extra blank row just before the page break.
On most of those cases there’s no cell padding at the top of the second part of the table.
We have been able to reproduce the problem using a slightly modified version of the example given on this page: Set Border Style, Margins and Padding of the Table - Aspose.Pdf for .NET
The code for the test console application is at the end of this post.
We used:
- Visual Studio 2008
- .Net Framework 3.5
- Aspose.PDF 6.0.0.0 for .Net 3.5
- Windows 7 Professional
Another “interesting” value for the width of the second column is 42%.
Can there anything be done about that behaviour?
Thanks,
Frank
using System;
using Aspose.Pdf.Generator;
namespace AsposePdfPageBreakSample
{
class Program
{
static void Main(string[] args)
{
//Instntiate the Pdf object by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
//Create the section in the Pdf object
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//Instantiate a table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
//Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);
//Set with column widths of the table
tab1.ColumnWidths = “20% 33% 20%”;
//Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
//Set table border using another customized BorderInfo object
tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
//Create MarginInfo object and set its left, bottom, right and top margins
Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
//Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin;
//Create rows in the table and then cells in the rows
for (int i = 0; i < 20; i++)
{
Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
row1.Cells.Add(“col1”);
row1.Cells.Add(“sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.”);
row1.Cells.Add(“col3”);
}
//Save the Pdf
pdf1.Save(“d:/pdf-temp/TableResult.pdf”);
}
}
}