How to get the current page count?

I have to create a PDF document from a grid view. When I try to count the total number of pages, I don't get the current amount. Dim pdfDoc As New Document(PageSize.A2, 50, 50, 50, 50) .......

I have to create a PDF document from a grid view. When I try to count the total number of pages, I don't get the current amount.

Dim pdfDoc As New Document(PageSize.A2, 50, 50, 50, 50) ................... pdfDoc.PageCount

Posted on StackOverflow on Jul 21, 2014 by Please help me

First of all you should create a PDF document in a right way. In iText 7 you’ll need:

PdfDocument pdfDoc = new PdfDocument(new PdfReader(src), new PdfWriter(dest));

Now you can refer to this object to know the number of pages in the document:

pdfDoc.getNumberOfPages();

Click this link if you want to see how to answer this question in iText 5.



Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now