Has anyone done a PDF Viewer type of component in ...
# compose
d
Has anyone done a PDF Viewer type of component in Compose? Would people generally just wrap existing libraries that were build for the old view system? Looking for the correct/good way of doing this, in a full compose app (don’t mind wrapping an android view tho if that’s what we have to do).
j
Are you wanting to view the pdf inside of your app or is opening it with another app sufficient? We did this in our app which is fully Compose but we just fired an Intent to open the app after downloading it so nothing really Compose specific for our usecase.
d
I want it to be shown in-app. When you say "we did this" do you mean you open it in another app?
I'm thinking of wrapping https://github.com/voghDev/PdfViewPager or similar in Compose
j
Yeah, we create a View Action intent and do startActivity on that, so it’ll show the PDF in whatever app they have that can read PDFs. For our testing that’s typically Google drive, but could be adobe or whatever.
d
Yeah unfortunately our requirements are to show the PDF in-app :/
j
I haven’t heard of any Compose specific things that’ll do that. I think wrapping an existing view-based library in a Compose AndroidView should work fine.
We used the WebView from Accompanist to do something similar with a WebView in our app so you can look at Google’s impl there for a good example of using AndroidView to do something like that
d
Yeah we've done it before too for other components like you said, I was just wondering if there is a better way to do it fully in Compose
j
Yeah, hopefully someone else has something good for you 🤞 , but I haven’t seen anything like that so far.
🤞 1
175 Views