You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Nick <ni...@hotmail.com> on 2013/01/29 17:42:34 UTC

Get coordinates of PDPageXYZDestination from bookmark




Hi Team,
I am using PDFBox to extract the bookmarks from a document. The bookmarks are known to be local, and they do indeed point to a page in the document. For the first bookmark, I've resolved its GoTo action destination to a PDPageXYZDestination object. Now, how do I retrieve the coordinates of where the PDF viewer would scroll to if the user clicked on that bookmark? Using: PDPageXYZDestination destination = ...; // Properly resolve the bookmark action to PDPageXYZDestinationint x = destination.getTop(); Does not point to the correct location. I tested this with the page drawer, which I've rendered a page in the PDF document with, then drew a line to represent where the PDPageXYZDestination is pointing to: PageDrawer drawer = new PageDrawer();
drawer.drawPage( graphics, page, dimension);PDRectangle cropBox = page.findCropBox();
graphics.drawLine( destination.getLeft(), destination.getTop(), (int) cropBox.getUpperRightX(), destination.getTop()); The line that is drawn is not in the same location as where my PDF viewer scrolls to. So, I believe my question can be summed up as, what are the correct coordinates to pass to graphics.drawLine() so the scroll point is correctly identified? The PDF I am attempted to parse is a Blackberry manual, located here: http://docs.blackberry.com/en/smartphone_users/deliverables/31849/BlackBerry_Torch_9810_Smartphone-User_Guide--1735726-0731051610-001-7.0-US.pdf Thanks for your help,Nick