alhappler/alh_pdf_view

Link Support ??? onLinkHandle

Closed this issue · 6 comments

onLinkHandle

Thank you for opening the issue @shubhamsinha2009
Could you provide some more information. Do you wish a function that is already available natively? And is it for Android and iOS?

Tap on url links in pdf goes to the chrome

@shubhamsinha2009 I implemented the callback onLinkHandle only for iOS because on Android, it didn't work.
If you override onLinkHandle , the default navigation to the browser is disabled and instead onLinkHandle will be called containing the clicked url. This feature comes with the next version 1.1.0

I've checked the changelogs but couldn't find. As of 2024, does it work on android as well?

Hello @mirkancal, I don't think so because the library wasn't updated since then, so I doubt that there is a function that could support the link now.

It should be simple as:

class DefaultLinkHandler(private val channel: MethodChannel) : LinkHandler {
    override fun handleLinkEvent(event: LinkTapEvent) {
        // Assuming LinkTapEvent has a method to get the URL or you might need to extract it
        val url = event.link.uri // Adjust this line according to the actual method available in LinkTapEvent
        val arguments = HashMap<String, String?>()
        url?.let { arguments["url"] = it }
        channel.invokeMethod("onLinkHandle", arguments)
    }
}

And for pdfViewConfigurator

.linkHandler(DefaultLinkHandler(alhPdfViewChannel))