Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adobe RM SDK Annotation

Tags:

ios

pdf

Have you guys used RM SDK for iOS? RM SDK saves annotation in the following format:

startBookmark = "#pdfloc(bd0d,0,101,5,2,0,0,1)";
endBookmark = "#pdfloc(bd0d,0,101,14,0,0,1,1)";

How can we get rect from these 2 lines?

like image 504
TechBee Avatar asked Mar 17 '15 09:03

TechBee


1 Answers

The PDF locations you have, point to a particular object in a PDF file. This object does not directly relate to an (x,y) coordinate on the screen, since that depends on the resolution and DPI you use to render the PDF file. It also depends on the rendering engine you use to render the file.

To draw a box in iOS, you will need to draw it using (x,y) coordinates. You need to get the (x,y) coordinates of the box that's around the annotations you are working with. You can do this with RMSDK using getRangeInfo. You can also use the PDF locations you have above, to navigate to the particular annotation. Note that the box you will get back is valid only for a rendition of your file, with the parameters you have. If you change any of the parameters - RMSDK version, navigation matrix values, dpi, rendering resolution, you will need to get new values for the box from RMSDK.

Here is some code that will help you get the (x,y) coordinates from your two locations using RMSDK. The code is for the main C/C++ library, since I'm not sure what your Objective-C layer looks like. It might be different depending on what version of RMSDK you are using.

dpdoc::RangeInfo* rangeInfo = renderer->getRangeInfo(startBookmark, endBookmark);
dpdoc::Rectangle* rect;
rangeInfo->getBox(0, false, rect&);

Then the "rect" variable will contain (x,y) coordinates, for the boxes you need to draw. Note that there might be multiple boxes for every 2 sets of coordinates. In that case, you will need to loop through them.

If you do have the Objective-C layer that usually comes with RMSDK, then it should be slightly easier. You code in that case should look something like this:

NSArray *boxes = nil;
RMRangeInfo *rangeInfo = [document getRangeInfoWithStart:startBookmark end:endBookmark];
boxes = rangeInfo.boxes

Then you can iterate through the array of boxes to get (x,y) and draw them on the screen. In most cases you will get 1 box, but you should account for cases where you have multiple boxes to draw. A simple loop should do the trick.

like image 103
Vel Genov Avatar answered Sep 30 '22 13:09

Vel Genov