How to get the current page count?

Tags: page numberspage countiText 7

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.