Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Regular Contributor
iruka
Posts: 79
Registered: ‎09-17-2012
My Device: Torch 9800

BB10 - Using HTML5 File API to Save Pdf

Hi all. I have been banging my head for days on how to allow user to view pdf attachment on the device. 

 

For some strange, using blackberry.invoke.invoke, the downloaded pdf file size is always zero. Got some advice from this forum to try blackberry.io.filetransfer.download. It was working fine the app is move to Workspace area. Whenever user try to download the pdf, it keeps returning error CONNECTION_ERR.

 

So I thought of trying to use HTML5 FIle API to donwload, but couldn'nt seem to find any example on using this API with pdf. 

 

Can anyone please help me? 

 

 

Developer
matizeitune
Posts: 366
Registered: ‎07-15-2013
My Device: blackberry Z10

Re: BB10 - Using HTML5 File API to Save Pdf

Use the FileTransfer API to download the file. In the API call's success callback you can then invoke the PDF viewer to view the file that was just downloaded. Much friendly for the user in my opinion.

 

 

https://developer.blackberry.com/html5/apis/blackberry.io.filetransfer.html

 https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/fileTransfer/app

 

 https://developer.blackberry.com/html5/apis/blackberry.invoke.html

https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/fileTransfer/app

 https://developer.blackberry.com/html5/documentation/invoking_core_apps.html

If you find this information useful please click like --->
@mezeitune on twitter
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: BB10 - Using HTML5 File API to Save Pdf

Hello iruka,

Sounds like you are trying to work with a PDF that is hosted externally; just to confirm, are you white-listing the domain that hosts the external PDF inside your config.xml file?
https://developer.blackberry.com/html5/documentation/access_element_834677_11.html

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Regular Contributor
iruka
Posts: 79
Registered: ‎09-17-2012
My Device: Torch 9800

Re: BB10 - Using HTML5 File API to Save Pdf

The domain hosting the pdf is included in the config.xml.

BlackBerry Development Advisor
chadtatro
Posts: 620
Registered: ‎10-01-2009
My Device: Z10

Re: BB10 - Using HTML5 File API to Save Pdf

[ Edited ]

I do this with images in an app I made. It should be pretty much exactly like this:

 

1. User clicks on something which says that they'd like to view the PDF

2. Use the FileTransfer API to download the file. The sample actually shows PDF as a usecase (https://github.com/blackberry/BB10-WebWorks-Samples/blob/master/fileTransfer/app/fileDownload.html)

3. In the SUCCESS function of the fileTransfer API call, you will then invoke Adobe Reader (https://developer.blackberry.com/html5/documentation/adobereader.html)

 

You may need to reference the actual Invoke API as well to make sure all your permissions, and features are setup in the config.xml. (https://developer.blackberry.com/html5/apis/blackberry.invoke.html)

 

Sounds like you may have some domain whitelisting issues if you're getting a connect error, or the URL is not proper. 

 

I tend to just disable Web Security in any of my apps which want to talk to more than a couple domains. Makes life easier, but admittedly is a bit of lazy coding on my part.  If you find that whitelisting the domain doesn't help, try this.

 

<feature id="blackberry.app">
    <param name="websecurity" value="disable" />
</feature>

 

 

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro