List of usage examples for org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination PDPageXYZDestination getZoom
public float getZoom()
From source file:com.quanticate.opensource.pdftkbox.PDFBookmark.java
License:Apache License
/** * Creates our Bookmark Wrapper from the outline item. * Handling Children (and tracking of levels) is up to * the calling class to manage//from w w w . ja va2 s. c om */ public PDFBookmark(PDOutlineItem current, int level) throws IOException { this.title = current.getTitle(); this.outlineItem = current; this.level = level; // Set defaults this.pageNumber = -1; this.yOffset = 0; // Find where the bookmark points to and record PDDestination dest = null; // Check for a bookmark via an action if (current.getAction() != null) { PDAction action = current.getAction(); if (action instanceof PDActionGoTo) { dest = ((PDActionGoTo) action).getDestination(); } } if (dest == null) { dest = current.getDestination(); } if (dest != null) { if (dest instanceof PDPageDestination) { PDPageDestination pdest = (PDPageDestination) dest; int pageNum = pdest.retrievePageNumber(); if (pageNum != -1) { this.pageNumber = pageNum + 1; } } if (dest instanceof PDPageXYZDestination) { PDPageXYZDestination xyz = (PDPageXYZDestination) dest; yOffset = xyz.getTop(); if (xyz.getZoom() > 0) { zoomType = ZoomType.ZoomPercent; zoom = Integer.toString((int) (xyz.getZoom() * 100)) + "%"; } else { zoomType = ZoomType.Inherit; } } else if (dest instanceof PDPageFitWidthDestination) { PDPageFitWidthDestination width = (PDPageFitWidthDestination) dest; yOffset = width.getTop(); zoomType = ZoomType.FitWidth; } else if (dest instanceof PDPageFitDestination) { zoomType = ZoomType.FitPage; } else if (dest instanceof PDPageFitHeightDestination) { zoomType = ZoomType.FitHeight; } else { System.err.println("TODO: Support destination of type " + dest); } // Set a zoom description from the type if needed if (zoomType != null && zoom == null) { zoom = zoomType.name(); } } else { System.err.println( "Warning - Non-destination bookmark " + current + " with action " + current.getAction()); } }
From source file:com.vns.pdf.impl.PdfDocument.java
License:Apache License
private ActionData parsePDDestination(PDDestination dest) throws IOException { if (dest != null) { if (dest instanceof PDNamedDestination) { return parsePDDestination( document.getDocumentCatalog().findNamedDestinationPage((PDNamedDestination) dest)); }/*www . jav a 2 s . c om*/ if (dest instanceof PDPageDestination) { float destZoom = -1; int destX = -1; int destY = -1; if (dest instanceof PDPageXYZDestination) { PDPageXYZDestination destXYZ = (PDPageXYZDestination) dest; destZoom = destXYZ.getZoom(); destX = destXYZ.getLeft(); destY = destXYZ.getTop(); } int destPage = ((PDPageDestination) dest).retrievePageNumber(); return destPage < 0 ? null : new ActionData(destX, destY, destPage, destZoom); } } return null; }