FlowDocument强制一个PageBreak(BreakPageBefore)

Dan*_*ter 9 .net c# wpf xaml

我正在使用C#创建一个FlowDocument并在表中填充数据.

例:

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"))));
Run Code Online (Sandbox Code Playgroud)

我希望能够在每个"部分"数据之后强制分页.我找到了BreakPageBefore,但无法弄清楚如何强制分页.

任何例子都太棒了!

谢谢.

mar*_*tin 17

如果我理解正确你想要这样做:

Section section = new Section();
section.BreakPageBefore = true;
section.Blocks.Add(table1);
flowDoc.Blocks.Add(section);
Run Code Online (Sandbox Code Playgroud)

如果你想在一张桌子内打破我建议做一张新桌子会更好.