Get the number of pages.
int pdfGetNumPages(PDFHandle pdf)
This function returns the number of pages in the currently open PDF file.

Internally, pages are numbered 1 to N, where N is the value returned by the pdfGetNumPages function, even if this doesn't match up with the document page numbering. For example, if a document has pages i-vii and 1-100, the PDF file will contain pages 1-107.

int n; n = pdfGetNumPages(pdf);