Skip to main content
Skip table of contents

How to get the current page count?

When I try to count the total number of pages, I don't get the current amount. Why is that?

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 How to get the current page count? if you want to see how to answer this question in iText 5.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.