if (isPageTreeNode(node)) for (COSDictionary kid : getKids(node)) if (isPageTreeNode(kid)) return get(pageNum, kid, encountered); return get(pageNum, kid, encountered);
public int getPageCount() { return doc.getPages().getCount(); }
PDPageTree pages = new PDPageTree((COSDictionary) parent); return pages.indexOf(new PDPage((COSDictionary) page));
private boolean findPage(SearchContext context, COSDictionary node) { for (COSDictionary kid : getKids(node)) { if (context.found) { break; } if (isPageTreeNode(kid)) { findPage(context, kid); } else { context.visitPage(kid); } } return context.found; }
/** * Returns the page at the given index. * * @param index zero-based index */ public PDPage get(int index) { COSDictionary dict = get(index + 1, root, 0); sanitizeType(dict); ResourceCache resourceCache = document != null ? document.getResourceCache() : null; return new PDPage(dict, resourceCache); }
/** * Returns the page at the given 0-based index. * <p> * This method is too slow to get all the pages from a large PDF document * (1000 pages or more). For such documents, use the iterator of * {@link PDDocument#getPages()} instead. * * @param pageIndex the 0-based page index * @return the page at the given index. */ public PDPage getPage(int pageIndex) // todo: REPLACE most calls to this method with BELOW method { return getDocumentCatalog().getPages().get(pageIndex); }
/** * A dictionary containing any resources required by the page. */ @Override public PDResources getResources() { if (pageResources == null) { COSBase base = PDPageTree.getInheritableAttribute(page, COSName.RESOURCES); // note: it's an error for resources to not be present if (base instanceof COSDictionary) { pageResources = new PDResources((COSDictionary) base, resourceCache); } } return pageResources; }
public PagePane(PDDocument document, COSDictionary pageDict, JLabel statuslabel) { page = new PDPage(pageDict); pageIndex = document.getPages().indexOf(page); this.document = document; this.statuslabel = statuslabel; initUI(); initRectMap(); }
increaseParents(parentDict);
/** * This will add a page to the document. This is a convenience method, that will add the page to the root of the * hierarchy and set the parent of the page to the root. * * @param page The page to add to the document. */ public void addPage(PDPage page) { getPages().add(page); }
/** * Returns all pages in the document, as a page tree. */ public PDPageTree getPages() { // todo: cache me? return new PDPageTree((COSDictionary)root.getDictionaryObject(COSName.PAGES), document); }
/** * Returns the index of the given page, or -1 if it does not exist. * * @param page The page to search for. * @return the zero-based index of the given page, or -1 if the page is not found. */ public int indexOf(PDPage page) { SearchContext context = new SearchContext(page); if (findPage(context, root)) { return context.index; } return -1; }
public PageEntry getPage(int index) { PDPage page = doc.getPages().get(index); String pageLabel = PDFDebugger.getPageLabel(doc, index); return new PageEntry(page.getCOSObject(), index + 1, pageLabel); }
/** * Returns the page at the given index. * * @param index zero-based index */ public PDPage get(int index) { COSDictionary dict = get(index + 1, root, 0); sanitizeType(dict); ResourceCache resourceCache = document != null ? document.getResourceCache() : null; return new PDPage(dict, resourceCache); }
/** * A rectangle, expressed in default user space units, defining the boundaries of the physical * medium on which the page is intended to be displayed or printed. */ public PDRectangle getMediaBox() { if (mediaBox == null) { COSBase base = PDPageTree.getInheritableAttribute(page, COSName.MEDIA_BOX); if (base instanceof COSArray) { mediaBox = new PDRectangle((COSArray) base); } } if (mediaBox == null) { LOG.debug("Can't find MediaBox, will use U.S. Letter"); mediaBox = PDRectangle.LETTER; } return mediaBox; }
private boolean findPage(SearchContext context, COSDictionary node) { for (COSDictionary kid : getKids(node)) { if (context.found) { break; } if (isPageTreeNode(kid)) { findPage(context, kid); } else { context.visitPage(kid); } } return context.found; }