I am trying to bundle my app with a PDF, and let the user open it in the native viewer.
I have tried:
- Copying the data for the PDF to the "Temporary Directory" or the "Document Directory" (from path_provider) and opening from there
- To open I am using 'url_launcher' to open the file. I have tried using both file:
//...urls and just passing the local path ie/.../etc
The files definitely exist, it seems to be a permissions issue that the files in both locations, in both platforms, are in the app's sandbox.
The file definitely exists, and I can open PDFs from web URLs.
is this something flutter can do?
Update 12/8/19
I just got pinged by SO that this question has had a bunch of views and no good answers. For this project I ultimately tried Cordova, Flutter, React Native and eventually gave up and created two native apps to do what I needed to do. They worked OK but the client wanted to make a bunch of UX changes.
So in the end I wrapped the code from the native side of things into a flutter plugin and then did the UX in flutter. Thats the backstory, here is the technical specs of what I hacked together:
For iOS there was an example of using their PDF kit in iOS 11 from github, I did some work there and there was a bunch of manually created features in the repo, so I attached the PDFs I wanted to that project, and wrote a script to present them, then used the flutter bridge to launch.
For Android it was much the same - I copied the files from the app bundle (not flutter assets) to a temp directory and then created a share link and launched the pdf using the native system viewer.
All in all it was a massive stuff around, no fault of Flutter's though, like I said, I used a bunch of multi platform frameworks and none of them would accomplish the job in a satisfactory way. Im sure a better dev could come up with a workable solution though.
Edit: It has been mentioned to use a combination of url_launcher and open_file. They work great for external files but do not work for bundled assets.