Free Support Forum - aspose.com

Auto Page numbering in Word using Aspose.Words

How can i set auto page numbering in Word using Aspose.Words? Also i want to display the page numbers in footer in the following pattern: “Page [Pagenumber] of [TotalPageNumbers]”.

You need to use DocumentBuilder for it. Here is an example:

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

builder.Write("Page ");

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

builder.Write(" of ");

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