Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FlowDocument Force a PageBreak (BreakPageBefore)

Tags:

c#

.net

wpf

xaml

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.

like image 867
Dan Bater Avatar asked Nov 10 '09 11:11

Dan Bater


1 Answers

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.

like image 68
martin Avatar answered Oct 15 '22 20:10

martin