PageBreakBefore
Contents
[
Hide
]ParagraphFormat.PageBreakBefore property
True if a page break is forced before the paragraph.
public bool PageBreakBefore { get; set; }
Examples
Shows how to create paragraphs with page breaks at the beginning.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set this flag to "true" to apply a page break to each paragraph's beginning
// that the document builder will create under this ParagraphFormat configuration.
// The first paragraph will not receive a page break.
// Leave this flag as "false" to start each new paragraph on the same page
// as the previous, provided there is sufficient space.
builder.ParagraphFormat.PageBreakBefore = pageBreakBefore;
builder.Writeln("Paragraph 1.");
builder.Writeln("Paragraph 2.");
LayoutCollector layoutCollector = new LayoutCollector(doc);
ParagraphCollection paragraphs = doc.FirstSection.Body.Paragraphs;
if (pageBreakBefore)
{
Assert.AreEqual(1, layoutCollector.GetStartPageIndex(paragraphs[0]));
Assert.AreEqual(2, layoutCollector.GetStartPageIndex(paragraphs[1]));
}
else
{
Assert.AreEqual(1, layoutCollector.GetStartPageIndex(paragraphs[0]));
Assert.AreEqual(1, layoutCollector.GetStartPageIndex(paragraphs[1]));
}
doc.Save(ArtifactsDir + "ParagraphFormat.PageBreakBefore.docx");
See Also
- class ParagraphFormat
- namespace Aspose.Words
- assembly Aspose.Words