To get number of pages in the PDF
import java.io.*;
import com.lowagie.text.pdf.PdfReader;
public class PDFSize {
//static String PdfName = "C:/pdfCount.pdf";
public int PDFPagesCount(String arg1) throws IOException
{
try{
PdfReader r = new PdfReader(arg1);
int NoOfPages =0;
NoOfPages =r.getNumberOfPages();
return NoOfPages;
}
catch (Exception e)
{
System.out.println(e.getMessage());
return 1;
}
}
public static void main(String args[]) throws IOException{
int PDF=0;
PDFSize pdfsize = new PDFSize();
try {
// pdfsize.PDFPagesCount(args[0]);
PDF= pdfsize.PDFPagesCount(args[0]);;
//System.out.println(new PDFSize().PDFPagesCount(PdfName));
} catch (Exception e) {
e.printStackTrace();
}
return PDF;
}
}