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

Free Support Forum - aspose.com

Page count not rendering for PDF document

I have a document which contains a letter followed by customer statement. The customer statement can vary from 4 to 10 pages.

I want to show page x of y in the footer of the customer statement where x and y are based on the statement excluding the letter.

Using the field NUMPAGES is not good since it includes the letter in the count.

Using document.pagecount works for WORD but not for PDF. (Hard coded values seem to work for PDF).

Here is the code


'set 3rd cell = 1/4 page width

builder.CellFormat.Width = TableWidth / 4

builder.Write("Page ")

builder.InsertField("PAGE", "")

builder.Write(" of ")

' builder.InsertField("NUMPAGES", "") works for Word and PDF but not good because it includes letter page in the count

Dim PageCount As String = "3" ' works but is hard coded, so no good

PageCount = (builder.Document.PageCount - 1).ToString ' works for Word, but does not render for PDF


Can you please advise if I am going wrong somewher or can you offer a workaround.

Many thanks for your ongoing support.


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved. As a workaround please try splitting your document to two sections (the first is Customer statement; the second is Letter) and try using the following code:


builder.CellFormat.Width = TableWidth / 4;

builder.Write("Page ");

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

builder.Write(" of ");

doc.FirstSection.PageSetup.RestartPageNumbering = true;

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


I attached the document which I use for testing.

Hope this helps.

Best regards,

Thanks, but this does not work for me. The Customer Statement document has several Sections, so using 'SECTIONPAGES' just gives the page count for each section.

Do you have any other suggestions please.


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Currently I cannot suggest you any way to work this problem around. You should just wait for the fix of the original issue.

Best regards,

The issues you have found earlier (filed as 11362) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan