Android Question PDFium - get page coordinates after pan or zoom?

GraemeW

Member
Licensed User
Longtime User
I'm trying to plot lat/lon points on a pdf document (specifically earthquake epicentres on a geology map). I have georeferenced the pdf bounds.

On one hand I have working code that uses the PDFium library to load the pdf into a HugeImageView, and the HugeImageView1_Updated event allows me to draw a point (epicentre) in an ImageView overlay which is correctly positioned over the pdf. The problem is the very long time required to create the HugeImageView initial bitmap, which is necessary for high pdf resolution.

On the other hand, the same pdf loads much faster, with high resolution, using the PDFview from the PDFium library, and pan and zoom gestures are built-in. The faster load makes this a preferred option.

However, among the many functions and properties available in the PDFium library I just cannot work out how to return the pdf page coordinates (in points or inches) of the visible part of the pdf after a pan or zoom. Has anyone any suggestions?

(PS Google/Gemini refers to a PDFview2 object and its ClientToPage( clientRect ) function but I can't find anything about it in the B4X PDFium library...)

Update clue: there is an otherwise undocumented event listed for the Configurator - Private Sub EventName_onLayerDrawn(cnvs As Canvas, arg1 As Float, arg2 As Float, arg3 As Int) which Google AI says has the information I want. However I get the error "java.lang.Exception: Sub pdfium_onlayerdrawn signature does not match expected signature." Now the problem is to find the correct signature...
 
Last edited:

GraemeW

Member
Licensed User
Longtime User
I now suspect the reason for the signature mis-match is because _onLayerDrawn event returns a canvas of type android.graphics.canvas which is not the same as a B4X canvas, and which I don't know how to catch and convert.

I'll now try to approach the problem from the other direction - using a ScaleImageView to pan and zooom an overlay image with the epicentre points, use its _onDraw event to capture the coordinate changes after pan and zoom, do some arithmetic involving coordinate bounds and scale, and move the underlying pdf to match the overlay image.
 
Upvote 0
Top