/** * 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; }
/** * Creates and adds new page with the specified page size. * * @param pageSize page size of the new page * @return added page */ public PdfPage addNewPage(PageSize pageSize) { checkClosingStatus(); PdfPage page = new PdfPage(this, pageSize); checkAndAddPage(page); dispatchEvent(new PdfDocumentEvent(PdfDocumentEvent.START_PAGE, page)); dispatchEvent(new PdfDocumentEvent(PdfDocumentEvent.INSERT_PAGE, page)); return page; }
/** * Creates and inserts new page to the document. * * @param index position to addPage page to * @param pageSize page size of the new page * @return inserted page * @throws PdfException in case {@code page} is flushed */ public PdfPage addNewPage(int index, PageSize pageSize) { checkClosingStatus(); PdfPage page = new PdfPage(this, pageSize); checkAndAddPage(index, page); currentPage = page; dispatchEvent(new PdfDocumentEvent(PdfDocumentEvent.START_PAGE, page)); dispatchEvent(new PdfDocumentEvent(PdfDocumentEvent.INSERT_PAGE, page)); return currentPage; }
PdfPage page = new PdfPage(dictionary); copyInheritedProperties(page, toDocument); for (PdfAnnotation annot : getAnnotations()) {