Display PDFs on Mobile device

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Bromo
Posts: 8
Joined: Fri Jan 16, 2015 12:04 am
Location: Ventura California

Display PDFs on Mobile device

Post by Bromo » Fri Feb 20, 2015 9:51 pm

Hello LiveCoders!

I have been trying to seek the answer for this question for a few weeks but have not been able to find a perfect solution. I am trying to create a standalone mobile app that can display multiple PDFs. I have reviewed the LiveCode Lessons and they seem to work fine for desktop and maybe they work for mobile but I'm not making the connection.

For example, using: launch document "Getting Started with Revolution.pdf"
allows me to select a PDF that has been saved to my desktop but where do I save a PDF in my app to make it standalone? Also, I've tried the web browser option but I need a PDF viewer that can operate without internet access.

Does anyone know if this is possible? I just want to look at a couple PDFs without internet access on my phone.

Klaus
Posts: 12090
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display PDFs on Mobile device

Post by Klaus » Sat Feb 21, 2015 4:23 pm

Hi Bromo,

the search function isn't really THAT bad, that one should not use it 8)

OK, what platform?
On iOS you can display a PDF file in a native browser object,
but there are no build-in capabilities on Android.


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5682
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Display PDFs on Mobile device

Post by jacque » Sat Feb 21, 2015 10:33 pm

Are you asking how to create PDFs from your stack content? Or something else?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2328
Joined: Sun Sep 23, 2007 4:58 pm

Re: Display PDFs on Mobile device

Post by SparkOut » Sat Feb 21, 2015 11:24 pm

Guessing the op really wants to know how to save a PDF along with all the assets of the standalone, and how to retrieve it for display via the standalone on mobile.
I'd give a more detailed answer assuming that's right, but it's painful on this phone

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: Display PDFs on Mobile device

Post by newtronsols » Sun Feb 22, 2015 3:35 pm

You could save a pdf on Google Drive and then use launch url to open it.

Or:

See http://livecode.com/livecode-7/embedded-web/

Bromo
Posts: 8
Joined: Fri Jan 16, 2015 12:04 am
Location: Ventura California

Re: Display PDFs on Mobile device

Post by Bromo » Sun Feb 22, 2015 10:12 pm

SparkOut wrote:Guessing the op really wants to know how to save a PDF along with all the assets of the standalone, and how to retrieve it for display via the standalone on mobile.
I'd give a more detailed answer assuming that's right, but it's painful on this phone
This is exactly what I'm trying to do. Assume there is no internet connection because you are lost deep in the mountains and therefore cannot access the web. I'd like to be able to pull out my phone and open up a couple of PDFs.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5682
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Display PDFs on Mobile device

Post by jacque » Mon Feb 23, 2015 5:47 pm

Sorry, I'm still confused. Where is the original content coming from? A downloaded PDF? A printout of the card or a field?

If you mean you want to save stack content, that's done with the "open printing" command using the pdf option.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2328
Joined: Sun Sep 23, 2007 4:58 pm

Re: Display PDFs on Mobile device

Post by SparkOut » Mon Feb 23, 2015 8:40 pm

He wants to bundle a PDF document with the standalone to be able to display it on mobile without being connected to internet services

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5682
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Display PDFs on Mobile device

Post by jacque » Tue Feb 24, 2015 8:03 pm

SparkOut wrote:He wants to bundle a PDF document with the standalone to be able to display it on mobile without being connected to internet services
Oh! Thanks for the translation SparkOut. Sorry to be so obtuse.

Bromo: There is no file picker on mobile but you can get "the files" to see a list of available files in a folder and then put that list into a field in your stack. That will allow you to select one of them to launch.

To include the pdfs in your app, I'd put them all into a folder and then add the whole folder to the Copy File pane in the Standalone Settings. When you build the standalone the folder will be included next to the engine. (There's a minor bug with file paths on iOS but it's being fixed. If that's an issue for you, let us know. There's a workaround.)

So now you have the pdf files in a folder that travels with your app and you need a script to get a selected file and launch it. The idea is:

set the defaultFolder to the one containing the pdf files
get the files
display them in a field

And to launch one of them:

get the text of the line the user clicks
launch that file

If you need help scripting that, let us know.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Bromo
Posts: 8
Joined: Fri Jan 16, 2015 12:04 am
Location: Ventura California

Re: Display PDFs on Mobile device

Post by Bromo » Wed Feb 25, 2015 4:22 pm

Jacque,

Thank you for your explanation. I am going to try this it sounds like it could work. You have given me a critical bit of information that I have been searching for. Is it possible for me to script a button so it automatically chooses a file within the folder or will the user always need to select the file?

Klaus
Posts: 12090
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display PDFs on Mobile device

Post by Klaus » Wed Feb 25, 2015 4:43 pm

Hi Bromo,
Bromo wrote:Is it possible for me to script a button so it automatically chooses a file within the folder...?
we hope so! :D

Yes sure, presumed you added your PDF file(s) via the "Copy files" TAB in the standalone builder settings as separate files,
you can find them in the final APP here -> specialfolderpath("engine")
...
put specialfolderpath("engine") & "/Name of your PDF here.pdf" into tFile
## Now do something with tFile :)
...

Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”