PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Table columns won't break onto a new page
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1616
Page 1 of 1

Author:  rambleOn [ Sat Apr 09, 2011 1:15 pm ]
Post subject:  Table columns won't break onto a new page

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

Author:  vmp5 [ Tue Jun 28, 2011 7:34 am ]
Post subject:  Re: Table columns won't break onto a new page

Hello

Did you get any solution for your problem, though im stuck in the same problem? i tried to read the source, but it doesn't seem to do much. I could only find

if (this.doHorizontalBreak)
{
CalcLastHeaderColumn();
CreateConnectedColumns();
}

in MigraDoc.Rendering.TableRenderer but as far as i see this canot be the logic. Is this feature really implemented for tables - do i miss something?

Regards, Klaus

Author:  Thomas Hoevel [ Tue Jun 28, 2011 8:32 am ]
Post subject:  Re: Table columns won't break onto a new page

Bad news: with the current implementation of MigraDoc columns do not break onto a new page.

Author:  GmServizi [ Wed Jul 13, 2011 4:21 pm ]
Post subject:  Re: Table columns won't break onto a new page

Hi all...

Is there any workaround for this?

This will be very helpfull for me..

Thanks a lot

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/