PageSetupPageStartingNumber Property

Gets or sets the starting page number of the section.

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

ExpandedSyntax

public int PageStartingNumber { get; set; }

Property Value

Type: Int32

ExpandedRemarks

The RestartPageNumbering property, if set to false, will override the PageStartingNumber property so that page numbering can continue from the previous section.

ExpandedExamples

Shows how to control page numbering per section.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Section 1");
builder.InsertBreak(BreakType.SectionBreakNewPage);
builder.Writeln("Section 2");

// Use document builder to create a header with a page number field for the first section
// The page number will look like "Page V"
builder.MoveToSection(0);
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.Write("Page ");
builder.InsertField("PAGE", "");

// Set first section page numbering
PageSetup pageSetup = doc.Sections[0].PageSetup;
pageSetup.RestartPageNumbering = true;
pageSetup.PageStartingNumber = 5;
pageSetup.PageNumberStyle = NumberStyle.UppercaseRoman;

// Create a header for the section
// The page number will look like " - 10 - ".
builder.MoveToSection(1);
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Write(" - ");
builder.InsertField("PAGE", "");
builder.Write(" - ");

// Set second section page numbering
pageSetup = doc.Sections[1].PageSetup;
pageSetup.PageStartingNumber = 10;
pageSetup.RestartPageNumbering = true;
pageSetup.PageNumberStyle = NumberStyle.Arabic;

doc.Save(ArtifactsDir + "PageSetup.PageNumbering.docx");

ExpandedSee Also