Page 1 of 1

Can LiveCode display PDF files on Mobile device?

Posted: Wed Jan 25, 2017 9:39 pm
by DR White
Can LiveCode Read PDF files?

Thanks,

David

Re: Can LiveCode Read PDF files?

Posted: Wed Jan 25, 2017 9:48 pm
by Klaus
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

Re: Can LiveCode Read PDF files?

Posted: Wed Jan 25, 2017 11:09 pm
by DR White
Klaus,

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

I don't see it in the dictionary.

Thanks,

David

Re: Can LiveCode Read PDF files?

Posted: Wed Jan 25, 2017 11:45 pm
by Klaus
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

Re: Can LiveCode Read PDF files?

Posted: Thu Jan 26, 2017 5:33 pm
by DR White
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

Re: Can LiveCode Read PDF files?

Posted: Thu Jan 26, 2017 5:59 pm
by Klaus
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

Re: Can LiveCode Read PDF files?

Posted: Thu Jan 26, 2017 6:11 pm
by DR White
Klaus,

WOW!!

That works Beautifully!!

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

Thanks so MUCH,

David

Re: Can LiveCode Read PDF files? - Solved

Posted: Thu Jan 26, 2017 6:19 pm
by Klaus
Hi David,

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


Best

Klaus

Re: Can LiveCode Read PDF files? - Solved

Posted: Thu Jan 26, 2017 8:50 pm
by DR White
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

Re: Can LiveCode Read PDF files?

Posted: Thu Jan 26, 2017 8:55 pm
by Klaus
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

Re: Can LiveCode display PDF files on Mobile device?

Posted: Fri Jan 27, 2017 3:20 pm
by DR White
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

Re: Can LiveCode display PDF files on Mobile device?

Posted: Fri Jan 27, 2017 3:45 pm
by Klaus
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

Re: Can LiveCode display PDF files on Mobile device?

Posted: Fri Jan 27, 2017 3:52 pm
by DR White
Klaus,

Made recommended changes, but still does not work.

Thanks,

David

Re: Can LiveCode display PDF files on Mobile device?

Posted: Fri Jan 27, 2017 4:01 pm
by Klaus
Sorry, I do not develop for mobile, so no brilliant ideas in the moment...

Re: Can LiveCode display PDF files on Mobile device?

Posted: Fri Jan 27, 2017 4:10 pm
by DR White
Klaus,

Your insight is always appreciated.

Thank Again,

David