Adding PDF's to project, then displaying them.

6 posts, 0 answers
  1. Sean
    Sean avatar
    18 posts
    Member since:
    Nov 2010

    Posted 26 Jan Link to this post

    I need to include about 60MB of PDF files into the project, then display them in the App.  I am familiar with File plugin and have used it, but I was wondering what is the ideal location to store them in the project, and then do I need to copy the files over to another location on first run of the application?  These files will be updated from time to time by a WebService.

     

    Any thoughts would be appreciated.

     

    Thanks.

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 Jan Link to this post

    Hi Sean,

    From the perspective of developing hybrid apps with AppBuilder, there are not specific recommendations to suggest on how to add a pdf file to the project. Since in Telerik Platform you can build various mobile applications leveraging Cordova, you can review Cordova plugins which would work better for you. 

    Regards,
    Dimitrina
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  3. Sean
    Sean avatar
    18 posts
    Member since:
    Nov 2010

    Posted 29 Jan in reply to Dimitrina Link to this post

    I am going to store them in a data directory initially, then copy them at start up to the persistent file area when they are updated.

     

  4. Carlos
    Carlos avatar
    69 posts
    Member since:
    Jun 2011

    Posted 01 Feb in reply to Sean Link to this post

    60MB is a huge file for the user to download and put on their phones. I would suggest hosting them on a site and let the user download it if they want.  Either put a link to it or host it.

     What we did was made a hosted site that I put a webpage up and uses PDF.js (https://mozilla.github.io/pdf.js/)

     You can then host your PDF there and let PDF.js render the PDF and there is a bunch of built in tools and a download button if the user wants to do that.

    PDF.js is great because you can have one webpage and append the PDF Url to the end with a Query string, and the PDF renders in the browser.  

    You can see an example here of what we did. The PDF has to be local on the same domain, otherwise you may run into some CORS issues, but it works great for us.

    http://econtent.dmns.org/home/join/memberships/catalyst/catalyst-viewer/?file=http://econtent.dmns.org/media/1258/february-march-2015-catatlyst-resized.pdf

     

     

  5. Sean
    Sean avatar
    18 posts
    Member since:
    Nov 2010

    Posted 04 Feb in reply to Carlos Link to this post

    Thanks Carlos for taking the time to reply.

     A couple of differences though, they need to have access to the PDF's if offline, and it isnt one big 60MB PDF, its 334 individual PDF's that appear as manufacturer alerts for a medical device.  The download isnt the problem, takes about 60 secs to download, but takes about 4 minutes to write them back to a DB on the phone.  Including them in the IPA then allowing them also to download seems to be the only solution so far.

     

  6. Carlos
    Carlos avatar
    69 posts
    Member since:
    Jun 2011

    Posted 04 Feb in reply to Sean Link to this post

    Ahhh . I see now.  Yes, that is probably your only solution.   
    We looked at doing this for our solution as well.  A Webservice that can ping the app and let the app know there is a new file.  I would definitely look at storing the PDF's onto the file system, not in the DB on the phone. From my understanding, the local DB on a phone is only about 100mb because it is running through web storage or webSQL (https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html).  And as you have seen is slow.  I don't even think the Web Storage is an active project anymore in HTML5.  Might want to be careful of that too.

     I would write directly to the phones file system. But have you app create a folder in the Phone's file system that all your PDF's would go to and that you would read and write from. 

    You would also use the Push Notification plugin or even the In-App notifications plug in (a little more robust) and let the user know they have a new PDF to download and they can then download it themselves.  

    Hope any of this helps. Sounds like you have a decent handle on a solution so far. Files are always tricky with mobile app development.

Back to Top