free
free

Reputation: 163

Migradoc: Avoid a page break in case of merged rows

When there isn't enough space left on a page, merged rows (cells) in table are placed into a new page.

How to prevent this and assure the table is filling the free space on the current page?

This picture shows, the problem

    Section section = document.AddSection();
    Table t5 = new Table();

    t5.AddColumn(Unit.FromCentimeter(4));
    t5.AddColumn(Unit.FromCentimeter(4));

    Row first = t5.AddRow();
    first.Cells[0].AddParagraph("Header 1");
    first.Cells[1].AddParagraph("Header 2");

    for (int j = 0; j < 4; j++)
    {
        var rowpd = t5.AddRow();
        rowpd.VerticalAlignment = VerticalAlignment.Center;
        rowpd.Cells[0].MergeDown = 17;
        rowpd.Cells[0].AddParagraph("Merged 18 cells. ");
        for (int i = 0; i < 18; i++)
        {
            if (i == 0)
            {
                rowpd.Cells[1].AddParagraph($"value {i}");
            }
            else
            {
                var row = t5.AddRow();
                row.Cells[1].AddParagraph($"value {i}");
            }
        }
    }
    document.LastSection.Add(t5);

Upvotes: 1

Views: 730

Answers (1)

MigraDoc does not (yet) split cells, it only splits between cells. With MergeDown you create a huge cell that will not split.

Option: Avoid the MergeDown and use many small cells on the left column without horizontal borders to achieve a similar optical effect, but with page breaking as expected. Depending on the text in the left column this may or may not be an option.

Upvotes: 2

Related Questions