Hi,
I'm having a problem rendering tables wider than the page. From what I've read the table should automatically split and columns going off beyond the right page edge should be moved onto a new page. However, I can't get it to work. The columns won't break and I don't know what I'm doing wrong.
With this sample method I get a table going beyond the page edge:
Code:
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using MigraDoc.Rendering.Printing;
using PdfSharp.Pdf;
public void SimpleTableTest()
{
int columnCount = 10;
int rowCount = 10;
Document document = new Document();
document.DefaultPageSetup.HorizontalPageBreak = true;
document.AddSection();
Table table = new Table();
table.Borders.Width = 0.5;
table.Rows.Height = 20;
for (int i = 0; i < columnCount; i++)
table.AddColumn(Unit.FromCentimeter(2.5));
Row headerRow = table.AddRow();
headerRow.HeadingFormat = true;
for (int i = 0; i < columnCount; i++)
headerRow.Cells[i].AddParagraph("Column " + i);
for (int i = 1; i < rowCount; i++)
{
Row row = table.AddRow();
for (int j = 0; j < columnCount; j++)
row.Cells[j].AddParagraph("value");
}
document.LastSection.Add(table);
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
pdfRenderer.Document = document;
pdfRenderer.RenderDocument();
pdfRenderer.PdfDocument.Save("testTable.pdf");
System.Diagnostics.Process.Start("testTable.pdf");
}
I am using MigraDoc 1.31 and .NET 3.5.
Any help will be very appreciated. Thanks
Anna