The PageNums field in the First Page footer does not show correctly

My environment:

Aspose.Words.14.6.0,

VS2013, .NET 4.5, Windows 8.1

MS Word 2010.



I want to show page index and page number in the footer. I created a doc using the following code, but when opened it with MS Word 2010, the page number showed incorrectly in the footer in the first page. But when I clicked it to edit, it showed correctly.



How can I fix it?



------------------------------------------

var doc = new Document();

var builder = new DocumentBuilder(doc);



var currentSection = builder.CurrentSection;

var pageSetup = currentSection.PageSetup;



pageSetup.DifferentFirstPageHeaderFooter = true;



// header for first page

builder.MoveToHeaderFooter(HeaderFooterType.FooterFirst);

pageSetup.HeaderDistance = 20;

builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

builder.Font.Name = “Arial”;

builder.Font.Bold = true;

builder.Font.Size = 14;

builder.Write(“Footer for first page.”);

builder.Write(" [");

builder.InsertField(“PAGE”);

builder.Write(" of “);

builder.InsertField(“NUMPAGES”);

builder.Write(”]");



// header for pages other than first

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;

builder.Write(“Footer for pages other than first.”);

builder.Write(" [");

builder.InsertField(“PAGE”);

builder.Write(" of “);

builder.InsertField(“NUMPAGES”);

builder.Write(”]");



// write some content to create a few pages

builder.MoveToDocumentEnd();

for (int i = 0; i
{

builder.Writeln(i.ToString());

}



doc.UpdateFields();

doc.Save(“test.doc”);

Hi Zach,


Thanks for your inquiry. It seems more like a bug in old version of MS Word 2010; this problem doesn’t occur when using Microsoft Word 2013. Also, Open Office Writer 4 displays the footer content correctly. If we can help you with anything else, please feel free to ask.

Best regards,