How to find out the Number of Pages in a Word document?

Hi All,

We have a functionality in which we need to auto populate some Word Document templates. We are using Aspose.Words to achieve this functionality.

The original templates are 1 page long. However, when we auto populate some fields in the template, the document may extend to more than 1 page. After we are done with all the auto population, we need to determine the number of pages in the final document.

We have tried using document.PageCount and doc.BuiltInDocumentProperties.Pages properties, but they do not provide the correct results. We have also tried calling the UpdatePageLayout() before reading the above properties, but still the correct page count is not available.

Can you please let us know a way to read the page count ?

Thanks,

Amit Dhadawe

Hi

Thanks for your inquiry. Could you please attach your template and show me the code which you use to populate the template with data.

Best regards,

Hi Andrey,

Please find the template and the code attached along with this post.

There is a table within the template which we populate based on the number of records present in the gridview on the screen.

When the number of rows in the table is large, the template extends into the 2nd page and the page count is still 1.

Thanks,

Amit Dhadawe

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 fixed.

Best regards,

I am doing the same thing and am having the same problem with page count.

What was the Fix?

Thanks

Mike

Hi Mike,

Thanks for your request. Could you please attach your documents and code here for testing? I will check the issue and provide you more information.

Best regards.

I am inserting text in bookmarks and this could cause the text to continue to the next page.

But I always get page count = 1

Dim intPages As Integer = Doc.BuiltInDocumentProperties.Pages

My goal is to append one page to the end of the template doc, but we print duplex, so I want to add an extra page before we append the new page, so it doesn’t not print on the back of the orginal doc.

Thanks

Mike

Hi Mike,

Thank you for additional information. I cannot reproduce the problem on my side. I tried with different value of bookmarks. Please try using the latest version of Aspose.Words (8.0.0).

https://releases.aspose.com/words/net/

Also, please attach your output document, which returns improper number of pages.

Best regards.

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


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