SectionPageSetup Property

Returns an object that represents page setup and section properties.

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

Syntax

public PageSetup PageSetup { get; }

Property Value

Type: PageSetup

Examples

Shows how to create a page border that looks like a wide blue band at the top of the first page only.
Document doc = new Document();

PageSetup pageSetup = doc.Sections[0].PageSetup;
pageSetup.BorderAlwaysInFront = false;
pageSetup.BorderDistanceFrom = PageBorderDistanceFrom.PageEdge;
pageSetup.BorderAppliesTo = PageBorderAppliesTo.FirstPage;

Border border = pageSetup.Borders[BorderType.Top];
border.LineStyle = LineStyle.Single;
border.LineWidth = 30;
border.Color = Color.Blue;
border.DistanceFromText = 0;

doc.Save(ArtifactsDir + "PageSetup.PageBorderProperties.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