briankitt wrote:
myDocument.DefaultPageSetup.BottomMargin = Unit.FromCentimeter(1);
This is bad practice. You should create a Clone() of DefaultPageSetup and modify that.
briankitt wrote:
string reportPath = ConfigurationManager.AppSettings["TempDir"] + Guid.NewGuid().ToString() + ".pdf";
This does not compile. A true SSCCE is a ZIP file with a solution that compiles right away.
KeepTogether is working as intended.
You have a single paragraph that is so long that it requires three pages. You tell MigraDoc to keep it together on a single page. This is
IMPOSSIBLE.
KeepTogether will only work properly if all paragraphs are small enough to fit on a single page.
Move
Code:
Paragraph myP = myDocument.LastSection.AddParagraph();
myP.Format.KeepTogether = true;
into the for loop and page breaks will always occur between "Line 8" and "Line 1".