tags:

views:

255

answers:

1

hi,

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.

+1  A: 

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.

martin
I'm not sure this is what I was after. I wanted a simple PageBreak kind of thing.TableData..TableData..<PageBreak>TableData...ETC...If this is what I'm after, I've missed it and could you explain please?Many Thank.
Dan Bater
Sounds like you want to start a new table for each section as martin suggests, eg <FlowDocument><Table PageBreakBefore="true"><TableData><TableData>...</Table><Table PageBreakBefore="true"><TableData><TableData>....
Ray Burns
I think like Ray it described in XAML it's the best way. Every Block-type has the PageBreakBefore-property you could use to say to the FlowDocument that it should break. I think there is no other way. So far i haven't found something like a PageBreak-type the explictly could make a page break.
martin