Free Support Forum - aspose.com

How to reset all pages number and reset it again

Hi Aspose,

I’m using Aspose.Words to append many documents to a destination file. The output result looks good, but the page number of whole page are displaying incorrect. Here is my case:
- Document 1: This doc contains 3 pages with page number is 1,2,3.
- Document 2: This doc contains 5 pages with page number is 8,9,10
- Document 3: This doc contains 6 pages with page number is 20,21,22,23,24,25,26

My question is: How to reset all pages number in the destination file after appending and re-apply it into this output? The page number in the new output must be increased from 1 to end.

Thanks.

Hi ChienVH,


Thanks for your inquiry. Please call Document.UpdateFields method before saving your final document as shown below:

<span style=“font-size:10.0pt;
font-family:“Courier New”;color:#2B91AF;mso-font-kerning:0pt;mso-ansi-language:
PL;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:
“Courier New”;mso-font-kerning:0pt;mso-ansi-language:PL;mso-no-proof:yes”> doc1
= new Document(MyDir

  • “input1.docx”);<o:p></o:p>

Document doc2 = new Document(MyDir + "input2.docx");

doc1.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);

doc1.UpdateFields();

doc1.Save(MyDir + "AsposeOut.docx");


I suggest you to read following documentation links for your kind reference. Please let us know if you have any more queries.

http://www.aspose.com/docs/display/wordsjava/How+to+Update+Fields
http://www.aspose.com/docs/display/wordsjava/Differences+in+Field+Update+in+Aspose.Words+10.0+and+Above

Thanks Tahir Manzoor, it works fine :slight_smile:

Hi ChienVH,


Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.