Opening PDF in local storage with File Viewer Plugin


In my mobile app I create a PDF with jsPDF, and it's saved locally with the help of the FilePlugin.
This all works fine. I can browse to the location of the internal storage, and open the generated PDF.

My issue is now that I can't open this PDF via the FileViewerPlugin.
If I use an external PDF via an URL, it works fine.

I'm using the URI provided by the SaveFile action of the FilePlugin, and I don't  get an ErrorMessage or an ErrorCode from the FileViewerPlugin, but the 'Success' flag is still false.

If I replace the "file:///" portion of the URI with "content:///" the PDF Viewer opens ('Success' Flag is true), but the PDF is still not showing up.

Below is an example of the URI I'm using:

Edit: the MIME Type is of course set to "application/pdf"

What am I missing?

Many thanks!

Anyone got an idea? Or is it best to move this to the Forge Discussions?


It's the new security from Android Nougat now reject file:/// uri.

The native code in cordova github must be updated to use the new FileProvider approach.

Sharing Files Between Apps

For apps targeting Android 7.0, the Android framework enforces the StrictMode API policy that prohibits exposing file:// URIs outside your app. If an intent containing a file URI leaves your app, the app fails with a FileUriExposedException exception.

To share files between applications, you should send a content:// URI and grant a temporary access permission on the URI. The easiest way to grant this permission is by using the FileProvider class. For more information on permissions and sharing files, see Sharing Files.

It's fixed in the original cordova plugin:

But it's not compatible with Outsystems (I tried), so we all have to wait for this plugin developer to implement it.


Ah, I see - thanks for the Info.

So we just have to wait and see until they update the plugin...

Problem is, this is not a supported plugin.

There's no confirmed date or will this ever be fixed.

Great news, it's been fixed. 

Check in Forge, go to File Viewer plugin, then check Version tab. 

Get version 1.2.0 (beta), it's working perfectly now.

Just pass file uri from File Plugin's SaveFile action.

You need to generate native APK again.

Thank you File Viewer Team for your time and effort. 

Hi Mr. Harlin! Nice to meet you here.

I'm Jonathan, I came across this forum discussion while trying to implement a PDF viewer for my mobile application. In my case, I tried to view the PDF file and also restrict the user from downloading it. I created a plugin based on this github:

After trying to implement it in my mobile application. It doesn't do anything or show something. If you don't mind would you please give me an insight on how to create a plugin correctly from github?

I'd be glad hearing back from you.

Thank you.


Jonathan Djuwandi