LastSection
Contents
[
Hide
]Document.LastSection property
Gets the last section in the document.
public Section LastSection { get; }
Remarks
Returns null
if there are no sections.
Examples
Shows how to create a new section with a document builder.
Document doc = new Document();
// A blank document contains one section by default,
// which contains child nodes that we can edit.
Assert.AreEqual(1, doc.Sections.Count);
// Use a document builder to add text to the first section.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hello world!");
// Create a second section by inserting a section break.
builder.InsertBreak(BreakType.SectionBreakNewPage);
Assert.AreEqual(2, doc.Sections.Count);
// Each section has its own page setup settings.
// We can split the text in the second section into two columns.
// This will not affect the text in the first section.
doc.LastSection.PageSetup.TextColumns.SetCount(2);
builder.Writeln("Column 1.");
builder.InsertBreak(BreakType.ColumnBreak);
builder.Writeln("Column 2.");
Assert.AreEqual(1, doc.FirstSection.PageSetup.TextColumns.Count);
Assert.AreEqual(2, doc.LastSection.PageSetup.TextColumns.Count);
doc.Save(ArtifactsDir + "Section.Create.docx");
See Also
- class Section
- class Document
- namespace Aspose.Words
- assembly Aspose.Words