public static int getPdfPageCount(File inputPdfFile) {
        PDDocument document = null;
        try {
            document = PDDocument.load(inputPdfFile);
            return document.getNumberOfPages();
        } catch (IOException ioe) {
            logger.error("Error counting PDF pages => " + ioe);
            return - 1;
        } finally {
            if (document != null) {
                try {
                    document.close();
                } catch (Exception e) {
                }
            }
        }
    }
public static int getPdfPageCount ( File inputPdfFile ) { PDDocument document = null ; try { document = PDDocument . load ( inputPdfFile ) ; return document . getNumberOfPages ( ) ; } catch ( IOException ioe ) { logger . error ( "Error counting PDF pages => " + ioe ) ; return - 1 ; } finally { if ( document != null ) { try { document . close ( ) ; } catch ( Exception e ) { } } } }
Gets PDF Page Count.

@param inputPdfFile input file
@return number of pages