Dan Bater
Dan Bater

Reputation: 323

FlowDocument Force a PageBreak (BreakPageBefore)

I'm using C# to create a FlowDocument and fill it with data within a table.

Example:

FlowDocument flowDoc = new FlowDocument();
Table table1 = new Table();
flowDoc.Blocks.Add(table1); 

table1.RowGroups.Add(new TableRowGroup());
table1.RowGroups[0].Rows.Add(new TableRow());
TableRow currentRow = table1.RowGroups[0].Rows[0];
table1.RowGroups[0].Rows.Add(new TableRow());

currentRow = table1.RowGroups[0].Rows[0];
currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Report"))));

I want to be able to force a page break after every 'section' of data. I have found the BreakPageBefore but cant figure out how to force a Page Break.

Any examples would be fantastic!

Thanks.

Upvotes: 10

Views: 9993

Answers (1)

martin
martin

Reputation: 2997

If I understand right you want to do this:

Section section = new Section();
section.BreakPageBefore = true;
section.Blocks.Add(table1);
flowDoc.Blocks.Add(section);

If you want to break within a table i suggest it would be better to make a new table.

Upvotes: 19

Related Questions