mituw16
mituw16

Reputation: 5250

MigraDoc not adding page breaks automatically

I am tasked with refactoring an old MigraDoc project written by a dev that is no longer with my company, and am having problems with the following bit of code..

var Split = new String[1];
Split[0] = "||";
if (invoiceObject.Note != null)
{
    var Lines = invoiceObject.Note.Split(Split, StringSplitOptions.RemoveEmptyEntries);
    for (var i = 0; i < Lines.Count(); i++)
    {
        if (i > 0)
            lineItemParagraph.AddLineBreak();

        lineItemParagraph.AddText("" + Lines[i].Replace(" ", " ").Replace("|", ""));

    }
}

This is working and it's taking a double pipe delimited notes fields and breaking it out into new lines as expected. The issue is that for very large note fields, the rendered PDF only has 1 page and the text just runs off the page. (The item I am testing with has enough data in the notes field for 20+ pages in the rendered PDF).

Edit

The code is inside of a text frame defined like this.

TextFrame lineItemFrame;
this.lineItemFrame = section.AddTextFrame();
this.lineItemFrame.Height = "3.0cm";
this.lineItemFrame.Width = "8.0cm";
this.lineItemFrame.Left = "0cm";
this.lineItemFrame.RelativeHorizontal = RelativeHorizontal.Margin;
this.lineItemFrame.Top = "9.0cm";
this.lineItemFrame.RelativeVertical = RelativeVertical.Page;

The Text frame is inside of a section that is defined like this. Looking through the code, it appears this is the only section on the PDF. Do I perhaps need more sections?

section = this.document.AddSection();
section.PageSetup.StartingNumber = 1;        

I can't figure out how to make MigraDoc add the page breaks for me automatically.

Am I missing something painfully obvious?

Upvotes: 3

Views: 2859

Answers (1)

MigraDoc adds page breaks automatically - with two exceptions: TextFrames do no break, table rows do not break. Tables break between rows only.

Upvotes: 4

Related Questions