PageSetupSectionStart Property

Returns or sets the type of section break for the specified object.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.9.0

Syntax

public SectionStart SectionStart { get; set; }

Property Value

Type: SectionStart

Examples

Shows how to specify how the section starts, from a new page, on the same page or other.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add text to the first section and that comes with a blank document,
// then add a new section that starts a new page and give it text as well
builder.Writeln("This text is in section 1.");
builder.InsertBreak(BreakType.SectionBreakNewPage);
builder.Writeln("This text is in section 2.");

// Section break types determine how a new section gets split from the previous section
// By inserting a "SectionBreakNewPage" type section break, we have set this section's SectionStart value to "NewPage" 
Assert.AreEqual(SectionStart.NewPage, doc.Sections[1].PageSetup.SectionStart);

// Insert a new column section the same way
builder.InsertBreak(BreakType.SectionBreakNewColumn);
builder.Writeln("This text is in section 3.");

Assert.AreEqual(SectionStart.NewColumn, doc.Sections[2].PageSetup.SectionStart);

// We can change the types of section breaks by assigning different values to each section's SectionStart
// Setting their values to "Continuous" will put no visible breaks between sections
// and will leave all the content of this document on one page
doc.Sections[1].PageSetup.SectionStart = SectionStart.Continuous;
doc.Sections[2].PageSetup.SectionStart = SectionStart.Continuous;

doc.Save(ArtifactsDir + "PageSetup.SetSectionStart.docx");
Shows how to construct an Aspose Words document node by node.
Document doc = new Document();

// A newly created blank document still comes one section, one body and one paragraph
// Calling this method will remove all those nodes to completely empty the document
doc.RemoveAllChildren();

// This document now has no composite nodes that content can be added to
// If we wish to edit it, we will need to repopulate its node collection,
// which we will start to do with by creating a new Section node
Section section = new Section(doc);

// Append the section to the document
doc.AppendChild(section);

// Set some properties for the section
section.PageSetup.SectionStart = SectionStart.NewPage;
section.PageSetup.PaperSize = PaperSize.Letter;

// A section needs a body, which will contain all other nodes that can be edited
Body body = new Body(doc);
section.AppendChild(body);

// The body needs to have at least one paragraph
// Note that the paragraph has not yet been added to the document, but we have to specify the parent document
// The parent document is needed so the paragraph can correctly work
// with styles and other document-wide information
Paragraph para = new Paragraph(doc);
body.AppendChild(para);

// We can set some formatting for the paragraph
para.ParagraphFormat.StyleName = "Heading 1";
para.ParagraphFormat.Alignment = ParagraphAlignment.Center;

// Now we can begin adding content to the document
Run run = new Run(doc);
run.Text = "Hello World!";
run.Font.Color = Color.Red;
para.AppendChild(run);

Assert.AreEqual("Hello World!" + ControlChar.SectionBreakChar, doc.GetText());

doc.Save(ArtifactsDir + "Section.CreateFromScratch.docx");

See Also