225
Views
6
Comments
Solved
Mobile Base64 pdf file to Image

Good Day Community,


I am trying to build a client action for an offline mobile application, the goal is to convert the local storage Base64 pdf file to an Image. I am trying to convert the data since I will be using the Image widget. 

Here is what I have done.

I tried to display the local Base64 pdf file directly using the HTML Encode Widget. On the mobile emulator of outsystems it works, however when installed as an apk it doesn't, read on some forums similar scenario.

I cannot use forge components which will prompt the pdf file to be displayed outside of the mobile application.

Any Ideas and documents will be highly appreciated. Thank you :) 

2020-05-07 18-53-00
Rui Barradas
 
MVP
Solution

Hello Leonard,

Hope you are doing well.


As suggested, here's what you can do:

1) Convert your file from Base64 to Binary Data using a client-side action. You can do that using JavaScript, doing something like:

2) Use SaveFile action from File Plugin to save your file (Binary Data) in the device.

3) Use OpenDocument action File Viewer Plugin to open this previous saved file (from its location that you can obtain from step 2).


Please be aware that the addition of a new plugin will always make you to generate your builds again and you are not able to test them on a browser, only using a real device.


Hope that this helps you! :)


Kind regards,

Rui Barradas

2021-05-05 13-05-18
Mykola (Nick) Tkachenko

Hi Leonard,

You can use JS libraries to achieve this. For example this one https://github.com/mozilla/pdf.js#online-demo 

UserImage.jpg
Leonard James Pena

Good Day Mykola (Nick) Tkachenko,

I am currently bewildered on using this JS libraries for outsystems. 

First problem I have will be having to call this Library without internet, the application I am trying to develop is an offline mobile. 

Second problem is the conversion part. I have seen on the example of pdf.js that it uses an external URL. As for me I will be using a file from local storage. 


Can I ask for some more information regarding your knowledge in implementing pdf.js on outsystems?


2021-05-05 13-05-18
Mykola (Nick) Tkachenko

I didn't work specifically with this library but had with other. It is possible to store library locally and use it offline. If library processes image by itself and not sending it to remote servers - URL is just a path to file.

UserImage.jpg
Leonard James Pena

Hi Mykola,

Thanks for your inputs when I tried to read the js my problem just seems to grow and grow. Since I have initially a base64 pdf instead of a direct pdf file I am required to create a script that will do the conversion. Since js is really not my forte I think I will have to skip on this for now since I have a deadline to meet. Right now someone suggested to me to use File Viewer Plugin and said that he was able to display it locally on mobile as an apk. Will be creating a new thread instead on using File Viewer Plugin.

2020-05-07 18-53-00
Rui Barradas
 
MVP
Solution

Hello Leonard,

Hope you are doing well.


As suggested, here's what you can do:

1) Convert your file from Base64 to Binary Data using a client-side action. You can do that using JavaScript, doing something like:

2) Use SaveFile action from File Plugin to save your file (Binary Data) in the device.

3) Use OpenDocument action File Viewer Plugin to open this previous saved file (from its location that you can obtain from step 2).


Please be aware that the addition of a new plugin will always make you to generate your builds again and you are not able to test them on a browser, only using a real device.


Hope that this helps you! :)


Kind regards,

Rui Barradas

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.