maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to open local File on the device (PDF...)

Just checked this... the changes will be compiled. Sorry about the misinformation at first.

Sjef Moling
Posts: 0
Joined: Thu Jan 23, 2014 10:00 am

How to open local File on the device (PDF...)

I changed the android code to be compatible with the 2.0 version of Appery:

// start - load local file
String urlFile = args.getString(0);
if (urlFile.startsWith("file:")){
try{
this.openLocalFile(args.getString(0));
} catch (JSONException e) {
status = PluginResult.Status.JSON_EXCEPTION;
browserCallbackContext.error(result);
} catch (IOException e) {
status = PluginResult.Status.IO_EXCEPTION;
browserCallbackContext.error(result);
}
browserCallbackContext.sendPluginResult(new PluginResult(status, result));
}
// end - load local file

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to open local File on the device (PDF...)

Hello Sjef,

thanks for sharing.

Marco Brenna
Posts: 0
Joined: Tue Jan 21, 2014 3:34 pm

How to open local File on the device (PDF...)

It seems a brilliant idea to change the childbrowser behaviour to open files with native code, thanks for sharing.
I'm trying to implement the code for Android but I'm having troubles.
I make the changes inside ChildBrowser.java; when I call the child browser inside my javascript with window.plugins.childBrowser.showWebPage("file:///mnt/myBill.pdf");
I get this error:

processMessage failed: Error: TypeError: Cannot read property 'childBrowser' of undefined

If I try to avoid window.plugins and call directly window.open it seems the program doesn't enter into childbrowser.java code.

I read that now Cordova implement inAppBrowser directly in core and I believe that window.open call exactly that code now and not the childBrowser.java one.

Is it that true? Is there a way for reach the same result of this brilliant forum post but with the core inAppBrowser or with other ways?

Thanks in advance for any reply,

Marco

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to open local File on the device (PDF...)

Marco,

"Cordova implement inAppBrowser directly in core and I believe that window.open exactly call that code" - Yes, it's true. You may find more information here: http://cordova.apache.org/docs/en/3.3...
But nothing prevents you to connect the plugin childBrowser and use it. http://devcenter.appery.io/documentat...

David Kleinschmidt
Posts: 0
Joined: Fri Jul 31, 2015 6:18 am

How to open local File on the device (PDF...)

Ok so i need to do this now, and this thread is 1 year old, and it would seem out of date.

Could i please have some CURRENT instruction on how to open a pdf file from the local file system.

I want to be able to:
1) open it locally
2) save it to a database (apperyio database)
3) have server code send it via SMTP to a email recipient.

incidentally the pdf file is being generated using jspdf.

Anyone?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to open local File on the device (PDF...)

Hello David,

1) did you use window.open? (https://getsatisfaction.com/apperyio/...)
2) You can upload files as shown here: https://devcenter.appery.io/documenta...
3) You can use any service for that, e.g. sendgrid: https://devcenter.appery.io/documenta...

Return to “Issues”