Page number and headers are not working

Dim header As New HeaderFooter(builder.Document, HeaderFooterType.HeaderPrimary)
Dim footer As New HeaderFooter(builder.Document, HeaderFooterType.FooterPrimary)
builder.Document.FirstSection.HeadersFooters.Add(header)
builder.Document.LastSection.HeadersFooters.Add(footer)
header.AppendParagraph(AuditName)
header.AppendParagraph(FinalReport)
footer.AppendParagraph("PAGE | ")
Dim para As Paragraph = footer.FirstParagraph
para.AppendField(“PAGE”)

@Jyothish,

Thanks for your inquiry. Please call Document.UpdateFields method before saving the document. Hope this helps you.

If you still face problem, please share the problematic and expected output document here for our reference. We will then provide you more information about your query.

Capture2.JPG (28.9 KB)
Capture1.JPG (72.5 KB)

       builder.InsertBreak(BreakType.LineBreak)
        builder.InsertHtml(Company)
        builder.Document.UpdateFields()
        doc.Save(Server.MapPath(“~”) + "Report\Report.docx")

page number and header is visible only in first page.Capture3.JPG (59.7 KB)

@Jyothish,
Perhaps you are using PageSetup.DifferentFirstPageHeaderFooter property or inserting the page field only in first section of document. If you are inserting the page field only in first section of document, you can link the headers and footers of sections to first section. Please use HeaderFooterCollection.LinkToPrevious method.

If you still face problem, please ZIP and attach your input Word, HTML and output document that shows the undesired behavior. Please also share the code example to reproduce this issue at our end. Thanks for your cooperation.