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

builder.InsertCell()
'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
builder.Write(PageCount)

Can you please advise if I am going wrong somewher or can you offer a workaround.
Many thanks for your ongoing support.

Hi

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.InsertCell();
builder.CellFormat.Width = TableWidth / 4;
builder.Write("Page ");
builder.InsertField("PAGE", "");
builder.Write(" of ");
doc.FirstSection.PageSetup.RestartPageNumbering = true;
builder.InsertField("SECTIONPAGES", "");
doc.UpdatePageLayout();

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.

Hi

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.
(13)

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