Can LiveCode display PDF files 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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Can LiveCode display PDF files on Mobile device?

Post by DR White » Wed Jan 25, 2017 9:39 pm

Can LiveCode Read PDF files?

Thanks,

David
Last edited by DR White on Thu Jan 26, 2017 11:34 pm, edited 3 times in total.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LiveCode Read PDF files?

Post by Klaus » Wed Jan 25, 2017 9:48 pm

Hi David,

on macOS and iOS you can display PDF files in a browser object/widget right out of the box,
on Windows the Acrobat Reader web plug-in has to be installed on the target machine.

No idea about Android, sorry.


Best

Klaus

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LiveCode Read PDF files?

Post by DR White » Wed Jan 25, 2017 11:09 pm

Klaus,

Where can I go to learn about using the browser widget?

I don't see it in the dictionary.

Thanks,

David

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LiveCode Read PDF files?

Post by Klaus » Wed Jan 25, 2017 11:45 pm

Hi David,

in the dictionary (LC >= 8) select "Browser" in the popup menu on the topleft side "Choose API: ..."!

Basically you drag a browser widget to a card, set its height and width and just set its url to an internet url or:
...
put specialfolderpath("resources") & "/pdf_files/a_pdf.pdf" into tPDFFIle
## The neccessary trick:
replace SPACE with "%20" in tPDFFile
set the URL of widget "your browser widget name here" to tPDFFile
...
You get the picture. :D


Best

Klaus

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LiveCode Read PDF files?

Post by DR White » Thu Jan 26, 2017 5:33 pm

Klaus,

Thanks for the help, but, I am not having any success.
There really is not much info on setting up the widget "Browser"

Would it be too much to give me a sample stack to view a PDF file?

Thanks,'

David

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LiveCode Read PDF files?

Post by Klaus » Thu Jan 26, 2017 5:59 pm

Hi David,

OK, here is a quick example. :D
Tested on my Mac and works with LC 9 dp4, but should of course work with all versions <= 8!


Best

Klaus
Attachments
browsertest.livecode.zip
(1.1 KiB) Downloaded 284 times

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LiveCode Read PDF files?

Post by DR White » Thu Jan 26, 2017 6:11 pm

Klaus,

WOW!!

That works Beautifully!!

Now, I will spend some time studying it to see how you did it.

Thanks so MUCH,

David

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LiveCode Read PDF files? - Solved

Post by Klaus » Thu Jan 26, 2017 6:19 pm

Hi David,

you're welcome!
But this is really no rocket science! :D


Best

Klaus

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LiveCode Read PDF files? - Solved

Post by DR White » Thu Jan 26, 2017 8:50 pm

Klaus,

My humblest apology. I should have mentioned that I was working on an IOS mobile app.

Your stack works great on desktop, but not on mobile.

Thanks,

David

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LiveCode Read PDF files?

Post by Klaus » Thu Jan 26, 2017 8:55 pm

Hm, try this:
1. add a PDF fle to the iOS standalone via the "Copy files" tab in the standalone builder settings
2. Use a little variation of my first script snippet:
...
put specialfolderpath("resources") & "/your_pdf_here.pdf" into tPDFFIle
## The neccessary trick:
replace SPACE with "%20" in tPDFFile
set the URL of widget "your browser widget name here" to tPDFFile
...
Should work on iOS, but maybe not in the simulator, which has some quirks, so they say... :D

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LiveCode display PDF files on Mobile device?

Post by DR White » Fri Jan 27, 2017 3:20 pm

Klaus,

I have tweaked your stack several ways, but could not get the mobile browser to display a PDF.
I have attached your stack with the changes that I made and also the pdf file that I
used.

Thanks for everyone's time and effort,

David
Attachments
CR65 Layout.pdf.zip
(178.64 KiB) Downloaded 205 times
browsertest.livecode 2.zip
(2.49 KiB) Downloaded 234 times

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LiveCode display PDF files on Mobile device?

Post by Klaus » Fri Jan 27, 2017 3:45 pm

Hi David,

use -> specialfolderpath("resources")
This happens to be the same as -> specialfolderpath("engine") on mobile,
but might change in future versions, since the ENGINE folder is really TABOO for us! :D

AND specialfolderpath("resources") does also work in the IDE, it returns the folder where (current) stack resides,
so no need to use anything else during development! But that should not hinder your PDF from being displyed!

Add two SLASHES to the URL and try again:

Code: Select all

...
set the URL of widget "Browser" to ("file://" & tPdfFile)
...

Best

Klaus

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LiveCode display PDF files on Mobile device?

Post by DR White » Fri Jan 27, 2017 3:52 pm

Klaus,

Made recommended changes, but still does not work.

Thanks,

David

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can LiveCode display PDF files on Mobile device?

Post by Klaus » Fri Jan 27, 2017 4:01 pm

Sorry, I do not develop for mobile, so no brilliant ideas in the moment...

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LiveCode display PDF files on Mobile device?

Post by DR White » Fri Jan 27, 2017 4:10 pm

Klaus,

Your insight is always appreciated.

Thank Again,

David

Post Reply