/** * Gets number of pages of the document. * * @return number of pages. */ public int getNumberOfPages() { checkClosingStatus(); return catalog.getPageTree().getNumberOfPages(); }
/** * Returns the {@see PdfPage} at the specified position in this list. * * @param pageNum one-based index of the element to return * @return the {@see PdfPage} at the specified position in this list */ public PdfPage getPage(int pageNum) { if (pageNum < 1 || pageNum > getNumberOfPages()) { throw new IndexOutOfBoundsException(MessageFormatUtil.format(PdfException.RequestedPageNumberIsOutOfBounds, pageNum)); } --pageNum; PdfPage pdfPage = pages.get(pageNum); if (pdfPage == null) { loadPage(pageNum); if (pageRefs.get(pageNum) != null) { int parentIndex = findPageParent(pageNum); pdfPage = new PdfPage(pageRefs.get(pageNum)); pdfPage.parentPages = parents.get(parentIndex); } else { LoggerFactory.getLogger(getClass()).error(MessageFormatUtil.format(LogMessageConstant.PAGE_TREE_IS_BROKEN_FAILED_TO_RETRIEVE_PAGE, pageNum + 1)); } pages.set(pageNum, pdfPage); } return pdfPage; }