/** * Returns the {@see PdfPage} by page's PdfDictionary. * * @param pageDictionary page's PdfDictionary * @return the {@code PdfPage} object, that wraps {@code pageDictionary}. */ public PdfPage getPage(PdfDictionary pageDictionary) { int pageNum = getPageNumber(pageDictionary); if (pageNum > 0) { return getPage(pageNum); } return null; }
/** * Gets the page by page number. * * @param pageNum page number. * @return page by page number. may return {@code null} in case the page tree is broken */ public PdfPage getPage(int pageNum) { checkClosingStatus(); return catalog.getPageTree().getPage(pageNum); }
/** * Gets the {@link PdfPage} instance by {@link PdfDictionary}. * * @param pageDictionary {@link PdfDictionary} that present page. * @return page by {@link PdfDictionary}. */ public PdfPage getPage(PdfDictionary pageDictionary) { checkClosingStatus(); return catalog.getPageTree().getPage(pageDictionary); }
/** * Removes the page at the specified position in this tree. * Shifts any subsequent elements to the left (subtracts one from their * indices). * * @param pageNum the one-based index of the PdfPage to be removed * @return the page that was removed from the list */ public PdfPage removePage(int pageNum) { PdfPage pdfPage = getPage(pageNum); if (pdfPage.isFlushed()) { Logger logger = LoggerFactory.getLogger(PdfPage.class); logger.warn(LogMessageConstant.REMOVING_PAGE_HAS_ALREADY_BEEN_FLUSHED); } if (internalRemovePage(--pageNum)) { return pdfPage; } else { return null; } }