Free Support Forum -

Page Numbers in Section Footer


How do I add page number in the section footer? I want to add 2 paragraphs in the footer. The first paragraph contains some text and the next paragraph should contain page Numbers. I can add the first paragraph (the some with Text) without any problem. But cannot seem to find how to add the page number in the next paragraph in the footer.

My Code:

// Get the Section

section = doc.Sections[sectionCounter];

// Add FooterPrimary to this section

HeaderFooter footerPrimary = new HeaderFooter(doc,HeaderFooterType.FooterPrimary);

section.HeadersFooters.Add(footerPrimary );

/* Start of First Para*/

Paragraph para1 = new Paragraph(doc);


para1.ParagraphFormat.Alignment = ParagraphAlignment.left;

para1.Font.Size = 10;

para1.AppendChild(new Run(doc,"My Text"));

/* End of First para*/




Try adding the following lines after /* End of First para */ comment:

//Add empty run

Run run1 = new Run(doc,"");


DocumentBuilder builder = new DocumentBuilder(doc);

// position builder just before run1


// insert PAGE autotext field

builder.InsertField("PAGE", "");