[File Viewer Plugin] [Mobile offline] Open PDF from entity's binary data

[File Viewer Plugin] [Mobile offline] Open PDF from entity's binary data

  
Forge Component
(3)
Published on 23 May (4 days ago) by OutSystems Experts
3 votes
Published on 23 May (4 days ago) by OutSystems Experts

How to open pdf (which is binary data in an entity) in offline mode ? Target is for both iOS and Android devices. I am able to display nicely when mobile is online. For offline mode, I tried below 




Unfortunately, this Forge component doesn't support opening/previewing files straight from their base64-encoded contents.

You can try to wrap the cordova-plugin-file-opener2 cordova plugin, which supports your use case through the openBase64() method, in an OutSystems plugin.

Check "Create a Plugin to Use Mobile Capabilities in Your Application" for more information on how to do this.

Pedro Sousa wrote:

Unfortunately, this Forge component doesn't support opening/previewing files straight from their base64-encoded contents.

You can try to wrap the cordova-plugin-file-opener2 cordova plugin, which supports your use case through the openBase64() method, in an OutSystems plugin.

Check "Create a Plugin to Use Mobile Capabilities in Your Application" for more information on how to do this.

Thanks Pedro.

Tried creating the plugin using CommonPlugin, but it fails as FileOpener undefined.Replacing FileOpener with FileOpener2 has same result.

if(typeof(cordova.plugins.FileOpener) === "undefined")
    $parameters.PluginExists = false;
else
    $parameters.PluginExists = true;




Mukul Varshney wrote:

Pedro Sousa wrote:

Unfortunately, this Forge component doesn't support opening/previewing files straight from their base64-encoded contents.

You can try to wrap the cordova-plugin-file-opener2 cordova plugin, which supports your use case through the openBase64() method, in an OutSystems plugin.

Check "Create a Plugin to Use Mobile Capabilities in Your Application" for more information on how to do this.

Thanks Pedro.

Tried creating the plugin using CommonPlugin, but it fails as FileOpener undefined.Replacing FileOpener with FileOpener2 has same result.

if(typeof(cordova.plugins.FileOpener) === "undefined")
    $parameters.PluginExists = false;
else
    $parameters.PluginExists = true;




Able to locate the problem and proceed,

if(typeof(cordova.plugins.fileOpener2) === "undefined")
    $parameters.PluginExists = false;
else
    $parameters.PluginExists = true;


Still it does not open the PDF file.

Hi,

Try using the File Plugin from Forge  to save the binary file locally. 

Use the File Plugin to save it locally. 

use the GetFileURI to get the path then place it in filePath in OpenDocument to open the binary file.




Valerie wrote:

Hi,

Try using the File Plugin from Forge  to save the binary file locally. 

Use the File Plugin to save it locally. 

use the GetFileURI to get the path then place it in filePath in OpenDocument to open the binary file.




Path property of the client action GetFileURI will be 

"data:application/pdf;base64," + JavaScript1.Base64

Is it correct ?

Solution

Hi using the File Plugin we used Create Directory to create a folder for the app in the phone then we used the SaveFile to save the binary file in the folder created. This path cannot be accessed unless the phone is jail break or rooted. so Example the path is "com/test/MobileApp"

Then for the GetFileURI that is the path that we put. 


Note that for the SaveFile no need to convert to base64 you can directly point the binary data from Local Storage.

Mukul Varshney wrote:

Valerie wrote:

Hi,

Try using the File Plugin from Forge  to save the binary file locally. 

Use the File Plugin to save it locally. 

use the GetFileURI to get the path then place it in filePath in OpenDocument to open the binary file.




Path property of the client action GetFileURI will be 

"data:application/pdf;base64," + JavaScript1.Base64

Is it correct ?



Solution