/** * Moves page to new place in same document with all it tag structure * * @param page page to be moved in document if present * @param insertBefore indicates before which page new one will be inserted to * @return <tt>true</tt> if this document contained the specified page */ public boolean movePage(PdfPage page, int insertBefore) { checkClosingStatus(); int pageNum = getPageNumber(page); if (pageNum > 0) { movePage(pageNum, insertBefore); return true; } return false; }
/** * Removes the first occurrence of the specified page from this document, * if it is present. Returns <tt>true</tt> if this document * contained the specified element (or equivalently, if this document * changed as a result of the call). * * @param page page to be removed from this document, if present * @return <tt>true</tt> if this document contained the specified page */ public boolean removePage(PdfPage page) { checkClosingStatus(); int pageNum = getPageNumber(page); if (pageNum >= 1) { removePage(pageNum); return true; } return false; }
for (PdfOutline pdfOutline : outlineList) { if (pdfOutline.getTitle().equals(outlineTitle)) { startPage = pdfDocument.getPageNumber(pdfPage); PdfOutline nextOutLine = getAbsoluteTreeNextOutline(pdfOutline); if (nextOutLine != null) { endPage = pdfDocument.getPageNumber(getPageByOutline(i, nextOutLine)) - 1; } else { endPage = size;
/** * Sets the /P and /A values corresponding to provided annotation, which is already added to a page. * * @param pdfAnnotation the annotation to be set * @param pdfDocument the corresponding document * @return this object wrapper */ public PdfTarget setAnnotation(PdfFileAttachmentAnnotation pdfAnnotation, PdfDocument pdfDocument) { PdfPage page = pdfAnnotation.getPage(); if (null == page) { throw new PdfException(PdfException.AnnotationShallHaveReferenceToPage); } else { put(PdfName.P, new PdfNumber(pdfDocument.getPageNumber(page))); put(PdfName.A, new PdfNumber(page.getAnnotations().indexOf(pdfAnnotation))); } return this; }
/** * {@inheritDoc} */ @Override protected LayoutArea updateCurrentArea(LayoutResult overflowResult) { if (currentArea == null) { int pageNumber = canvas.isCanvasOfPage() ? canvas.getPdfDocument().getPageNumber(canvas.getPage()) : 0; currentArea = new RootLayoutArea(pageNumber, canvas.getRootArea().clone()); } else { setProperty(Property.FULL, true); currentArea = null; } return currentArea; }
/** * {@inheritDoc} */ @Override protected LayoutArea updateCurrentArea(LayoutResult overflowResult) { if (currentArea == null) { int pageNumber = canvas.isCanvasOfPage() ? canvas.getPdfDocument().getPageNumber(canvas.getPage()) : 0; currentArea = new RootLayoutArea(pageNumber, canvas.getRootArea().clone()); } else { setProperty(Property.FULL, true); currentArea = null; } return currentArea; }
/** * Get the page number associated to the provided widget. * * @param widget PdfWidgetAnnotation from which to extract the page number * @return page number */ protected int getWidgetPageNumber(PdfWidgetAnnotation widget) { int pageNumber = 0; PdfDictionary pageDict = widget.getPdfObject().getAsDictionary(PdfName.P); if (pageDict != null) { pageNumber = document.getPageNumber(pageDict); } else { for (int i = 1; i <= document.getNumberOfPages(); i++) { PdfPage page = document.getPage(i); if (!page.isFlushed()) { if (page.containsAnnotation(widget)) { pageNumber = i; break; } } } } return pageNumber; }
/** * Get the page number associated to the provided widget. * * @param widget PdfWidgetAnnotation from which to extract the page number * @return page number */ protected int getWidgetPageNumber(PdfWidgetAnnotation widget) { int pageNumber = 0; PdfDictionary pageDict = widget.getPdfObject().getAsDictionary(PdfName.P); if (pageDict != null) { pageNumber = document.getPageNumber(pageDict); } else { for (int i = 1; i <= document.getNumberOfPages(); i++) { PdfPage page = document.getPage(i); if (!page.isFlushed()) { if (page.containsAnnotation(widget)) { pageNumber = i; break; } } } } return pageNumber; }
return; int fromNum = document.getPageNumber(from); if (fromNum == 0 || fromNum == insertBefore || fromNum + 1 == insertBefore) return;
if (xObjectResources != null && pageResources != null && xObjectResources == pageResources) { xObject.getPdfObject().put(PdfName.Resources, initialPageResourceClones.get(document.getPageNumber(page)));
if (xObjectResources != null && pageResources != null && xObjectResources == pageResources) { xObject.getPdfObject().put(PdfName.Resources, initialPageResourceClones.get(document.getPageNumber(page)));
pageLabel.put(PdfName.St, new PdfNumber(firstPage)); getDocument().getCatalog().getPageLabelsTree(true).addEntry(getDocument().getPageNumber(this) - 1, pageLabel); return this;