KevinnZou / compose-webview-multiplatform

WebView for JetBrains Compose Multiplatform
https://kevinnzou.github.io/compose-webview-multiplatform/
Apache License 2.0
318 stars 40 forks source link

Open and display linked PDF files #50

Closed mjacome closed 6 months ago

mjacome commented 6 months ago

Hi, thanks for providing this lib, it has worked very well for our project so far.

It would be great if you could add support for loading PDFs that are linked from a page. At the moment, if I click on a link such as

<a href="https://www.foobar.com/randomfile.pdf" title="randomfile.pdf" download="randomfile.pdf" target="_blank"> nothing happens.

According to https://stackoverflow.com/questions/30461392/android-pdf-not-loading-in-browser-and-webview, if this were only on Android, we could override shouldOverrideUrlLoading in the WebViewClient to obtain the behavior we want. However, its not clear if this would actually be the solution, but its worth exploring.

Have you come across this issue before? Many thanks

KevinnZou commented 6 months ago

@mjacome Thanks for your feedback. I tried to load this https://docs.google.com/gview?embedded=true&url=http://www.expertagent.co.uk/asp/in4glestates/{16D968D6-198E-4E33-88F4-8A85731CE605}/{05c36123-4df0-4d7d-811c-8b6686fdd526}/external.pdf directly and it works good. I also tested it with a link inside the page and it also works well. Did you add this https://docs.google.com/gview?embedded=true&url= prefix?

mjacome commented 6 months ago

Thanks, the https://docs.google.com/gview?embedded=true&url= prefix works but that seems like a workaround, especially since I don't have access to change the websites with the linked PDFs. I created an Android Compose project and tried it out there, and it doesn't work there either, so its an issue of Accompanist and/or Android WebView, not really an issue for this project. Will close this issue for now.