Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get X and Y coordiantes on tap #1224

Open
tevzselcan opened this issue Feb 4, 2025 · 1 comment
Open

How to get X and Y coordiantes on tap #1224

tevzselcan opened this issue Feb 4, 2025 · 1 comment

Comments

@tevzselcan
Copy link

How can I get the X,Y coordinates when the user taps on a PDF? I have tried many times, but still can't exactly get the X and Y coordinates that would be correct. The solution that seems the most useful would be this:
#757 (comment)

but I can't access the pdfFile variable, since it is not accessible from outside the package:
'pdfFile' is not public in 'com. github. barteksc. pdfviewer. PDFView'. Cannot be accessed from outside package.

Is there another workaround? I need the X,Y coordinates to send them to a web service along with the PDF file where some text will be inserted at the provided coordinates.

Thanks!

@enriquebautista
Copy link

enriquebautista commented Feb 14, 2025

@tevzselcan I've just finished solving it...

I recommend you to use the fork of this library:
AndroidPdfViewer fork

You can clone the library and make some adjustments, if you need the pdfFile you can expose a method in the PdfView:
public PdfFile getPdfFile() { return pdfFile; }

and set public class PdfFile
because PdfFile is package visibility.

Now in order to make use of the function convertScreenPointToPdfPagePoint() you have to make changes in the pdfium-android library.

Currently in the library they use:
api 'com.github.barteksc:pdfium-android:1.9.0'.

But that library does not have the function you mention, since it is a pull request that was closed (I don't understand why).

I tried to add pdfium-android and implement the functions manually but it brings problems with the ndk and some .so that are not compiled in the apk.

After so much, what a surprise “Infomaniak” has already fixed it and we can make use of it, moreover, he already applied the convertScreenPointToPdfPagePoint() method and update proyect !!!
Credits:
Pdfium fork

With this you have everything to obtain the correct X,Y point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants