We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Current page number in XML to PDF


We are exploring XML to PDF conversion and we gave a try to adding the current page number in the header of the generated PDF using the $p / $P in the item.

The generated PDF will show 1 / 3 for all 3 pages.

I attached the app we are using XmlToPdf.zip (5.4 KB).

Can you please let us know what are we doing wrong there?

Thank you!


We managed to replicate the problem of incorrect page numbering in our environment. An investigation has been logged under the ticket ID PDFNET-44806 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

I was wondering if there has been any progress on this bug. I am seeing this same problem within my application.



We are afraid that the earlier logged ticket has not been yet resolved due to other pending issues in the queue. However, could you please confirm if you are trying this with 22.6 version of the API? Please share your sample files as well so that we can test them in our environment and address the issue accordingly.


Thank you for responding. I verified that I am running 22.6 of the PDF API. I decided to attempt a different approach and use a page number stamp (as found here https://docs.aspose.com/pdf/net/add-page-number/).

What I find interesting, is that I have a similar problem with this solution. In this situation, although my code is numbering each page, it only thinks there is one page and puts the stamp on that (1 of 1 when there are actually 3 printable pages each with their own header).

What I think is happening in both situations is that due to how I have the XML formatted, although the content is spread across multiple printed pages, the PDF API thinks that everything is that first page.

If I save the PDF and then reopen and number the pages using the stamp, it works correctly (but is not a practical solution within my program). I am including the XML that I am using to generate the PDF. I can’t break the different sections into different pages as I want to fit as much content per page as I can and the content of each program is going to be different so the lengths of the pages will be different.

Hopefully, this makes sense.

Jonathan Kressin

ProgramReport_Standard.zip (1.0 KB)


Thanks for providing more details. We have created another ticket as PDFNET-52088 in our issue tracking system for your case. We will investigate it in details and will inform you in this forum thread as soon as the issue is resolved. Please spare us some time.

We apologize for your inconvenience.