How to get PdfViewCtrl class OverlayView frame size in android?

Product:PDFTron Android SDK

Product Version:Demo

Please give a brief summary of your issue:How to get PdfViewCtrl class OverlayView frame size in android?
(Think of this as an email subject)


From this above,
mPdfViewCtrl.canvasWidth & mPdfViewCtrl.canvasHeight helps me to get canvas size details( L1). How could i get L2 (mPdfViewCtrl overlayvew frame size details )?

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Manoj,

Thanks for contacting us.
Could you please let us know what is your use case? what are you going to do with this L2 frame size?

Best regards,
Saeed

Hi Saeed,
Thanks for the reply. I wanted to calculate screen point from the all kind of Page point. I know we have one method to convert page point from screen point in PDFTron. But, problem is in my current running app, the used pdf library is calculation page point with reference of bottom-left point. It doesn’t change the reference point as per the page rotation. When i try to render same annotation with the saved page point position using PDFTron. The position of annotation is different. This is obvious because PDFTron calculation is different with my current used pdf lib. So i wanted to give a try using deltaX & deltaY to make common reference screen point from all kind of page point. To calculate deltaX & deltaY i need overlay view size.

For Ex:


page point( 396, 306) For both the cases pdf page has rotated 90 degree.

  1. From pic-1:
    Current app is taking reference point is left-bottom (always), it added annot at (396,306)

  2. From pic-2: ( Using PdfTron)
    Reference point is at top-left as pdf has rotated 90. So the position has changed.

Could you please help me if i can able to get this overlay view frame size, i will give a try.
or what should be suggested to get reference point always at bottom-left?

Thank you.

Hi,

Thanks for the additional information.

Just to clarify, currently you have a number or coordinates from your app that always reference the origin as the bottom left of the page as shown in the viewer, no matter the rotation. Now you would like to use these page coordinates to add annotations to the page using PDFTron API. Is that correct?

If this is the case, there are a number of solutions:

Solution 1. You will need to calculate the proper page coordinates (to be used with PDFTron API) from your existing coordinates. For example you will need to determine the rotation of the page, calculate the bounding box for the annotation, and then set the rotation of the annotation.

Also, as mentioned previously: Can i get fixed PDF page co-ordinates (Bottom-left point ) irrespective of Pdf page rotation? - #4 by Ryan , the GetDefaultMatrix API may be helpful in this case.

Solution 2. A simpler solution would be to create an XFDF using your current PDF library and import the XFDF using the PDFTron API. We suggest going with this option if possible.

If this is not what you’re looking for, would it be possible if you could send us a concrete example? For example some detailed steps to recreate your flow with a sample PDF, example page points, sample code, etc…? If possible, a sample project would also be very helpful.

Hi,

I had to do calculation for each rotation. This works.
Could you please help me if i can able to get this overlay view frame size, i will give a try with this as well.

And, could you please help on this query as well How to add a Button/view above on PdfViewCtrl overlayview?
Thanks.

Hi,

I’m glad you were able to resolve the rotation issue.

As for overlay view frame size, could you describe how you are using this? I assume you are trying to use the frame size to add a custom button on top of PDFViewCtrl? Is that so?

If not, could you describe in detail what you are using the frame size for?

Hi

I am asking this overlay view findings is to fix for rotation issue only. I just wanted to do some try using this frame size. But anyway this works. Thanks.

Could you please help here How to add a Button/view above on PdfViewCtrl overlayview?

Hi Manoj,

Sure thing, we’ll move the discussion to the other topic.