Could you please let me know if it is possible to get an annotation's
size (i.e. width and height) and position with regards to the screen
size in Android. I have tried using Rect but it seems it's dimensions
are specific to the PDF. These dimensions do not seem to change when
you zoom or change page orientation.
I am trying to locate youtube annotations and then overlay them with a
view that has the youtube video embedded. However, I am not able to
overlay the video directly on top of the annotation because the Rect
dimensions do not correspond to the screen. I would like to get the
annotation dimensions as well as relative position w.r.t. screen, i.e.
the left and top margins.
Can you also let me know how I can identify both pages when screen
layout is in Landscape and page presentation mode is set to FACING. In
this mode the viewer displays two pdf pages at once therefore I am not
able to get all the annotaions for both pages on
mPDFView.setPageChangeListener... onPageChange().
Note that the bbox is specified in page space, which is independent of how the document is viewed.
Now that you know a point in page space, you can use PDFViewCtrl.convPagePtToClientPt() to convert it to client space (the viewing region of PDFViewCtrl). Suppose (x, y) is in client space, then (a, b) is in
PDFViewCtrl Canvas space, where a = x+PDFViewCtrl.getScrollX() and b = y+PDFViewCtrl.getScrollY(). With (a, b) available, you can easily add a child view to PDFViewCtrl. If you simply want to overlay
another widget on top of PDFViewCtrl in screen space, you can first compute PDFViewCtrl’s location in screen space using getLocationOnScreen() and suppose it is (s, t). Then (s+x, t+y) would be the upper-left corner of the widget that you want to overlay upon PDFViewCtrl.
When in FACING mode, PDFViewCtrl displays two pages at a time and PDFViewCtrl.getCurrentPage() will give you the page that occupies more client space. Regardless, with one page number available from the two pages, you should be able to find the other page number easily and then find all the annotations.
However, how do i track the size of the annotation relative to the screen. It seems as if I am getting the same annotation size regardless of zoom, page orientation, etc.
If my page is in landscape, the pages and annotations are much smaller because the app defaults to FACING. The anntation size remains the same nonetheless.
Not problem. I am glad to hear it works out. Yes, since PDF page space’s origin is at the lower-left corner and the Y-axis goes up and the client/screen space has its origin at the upper-left corner and the Y-axis goes down. The “upper-left” corner of the annotation in page space should be ( r.getX1(), r.getY2() ).
Do you mean “How does PDFViewCtrl know of zoom…”? PDFViewCtrl provides various event feedbacks to users and the best way to listen to them is through the PDFViewCtrl.ToolManager and PDFViewCtrl.Tool interface. There is detailed explanation in the following thread: