Footer Page Number

Hello,
Can You suggest that how can start a footer numbering with 1 from a 3 page.

@RiteshK10 In this case the 3rd page should start from new section and the section should have PageSetup.RestartPageNumbering set. For example see this following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
            
builder.Writeln("This is the first page");
builder.InsertBreak(BreakType.PageBreak);
builder.Writeln("This is the second page");

// Insert a section break.
builder.InsertBreak(BreakType.SectionBreakNewPage);
builder.PageSetup.RestartPageNumbering = true;
builder.PageSetup.PageStartingNumber = 1;

// Insert page field into the promary footer.
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.InsertField(FieldType.FieldPage, false);

// Insert few pages.
builder.MoveToDocumentEnd();
for (int i = 0; i < 5; i++)
{
    builder.Writeln($"Page {i}");
    builder.InsertBreak(BreakType.PageBreak);
}

doc.Save(@"C:\Temp\out.docx");

out.docx (7.6 KB)

Hello, Can you suggest one thing more please that how can set for first two page footer numbering with roman number ‘I,II’ and rest of pages with footer numbering start with ‘1,2,3’

@RiteshK10 You should use PageSetup.PageNumberStyle property to configure style of page numbers. For example see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert page field into the promary footer.
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.InsertField(FieldType.FieldPage, false);
// Configure page number style
builder.PageSetup.PageNumberStyle = NumberStyle.UppercaseRoman;
builder.MoveToDocumentEnd();

builder.Writeln("This is the first page");
builder.InsertBreak(BreakType.PageBreak);
builder.Writeln("This is the second page");

// Insert a section break.
builder.InsertBreak(BreakType.SectionBreakNewPage);
builder.PageSetup.RestartPageNumbering = true;
builder.PageSetup.PageStartingNumber = 1;

// Insert page field into the promary footer.
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.InsertField(FieldType.FieldPage, false);
// Configure page number style
builder.PageSetup.PageNumberStyle = NumberStyle.Arabic;

// Insert few pages.
builder.MoveToDocumentEnd();
for (int i = 0; i < 5; i++)
{
    builder.Writeln($"Page {i}");
    builder.InsertBreak(BreakType.PageBreak);
}

doc.Save(@"C:\Temp\out.docx");

out.docx (8.0 KB)