I found solution for this but i think it is unnecessary to check the below things and solution is not a efficient way of getting the total pdf page numbers.private int getNumberOfPages(PdfReader reader) { int pages = 0; PdfObject obj; for (int i = 1; i <= reader.getXrefSize(); i++) { obj = reader.getPdfObject(i); if (obj != null && obj.isStream()) { PRStream stream = (PRStream)obj; byte[] b; try { b = PdfReader.getStreamBytes(stream); PdfReader pdfReader = new PdfReader(b); pages += pdfReader.getNumberOfPages(); } catch(InvalidPdfException e) { } catch (IOException e) { } } } if (pages == 0) { pages = reader.getNumberOfPages(); } return pages; } 这篇关于如何使用IText或使用Java的任何函数获取Portable Collection Pdf的页数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-16 20:11