Page 1 of 2

Display PDF in android device

Posted: Sun Mar 24, 2013 1:39 pm
by terryho
Hi all

Can anyone help me to view a preloaded PDF file in android device?

I use the following example code, which can view PDF file in iOS device, but it cannot work in android device.

On preOpenCard
# create the browser
MobileControlCreate "browser"
put the result into sBrowserId
put "file://" & specialfolderpath("engine") & "/sample.pdf" into tLocalPDF

# set up the basic defaults
MobileControlSet sBrowserId, "rect" , the rect of group "Browser"
MobileControlSet sBrowserId, "visible" , "true"
## Then set the iOS browser to that URL
MobileControlSet sBrowserId, "url", tLocalPDF
end preOpenCard

Does it need special command for android device?

Regards

Terry Ho

Re: Display PDF in android device

Posted: Sun Mar 24, 2013 9:28 pm
by Simon
Hello Terry,
Android browser does not support .pdf viewing.
...it cannot work in android device
You have it right :D

Simon

Re: Display PDF in android device

Posted: Wed Oct 30, 2013 12:47 pm
by juanjo
Any other way to display a PDF in Android?

Re: Display PDF in android device

Posted: Thu Oct 31, 2013 2:21 pm
by Klaus
Hi Terry,

I read this one on the mailing list, maybe this will help:
http://stackoverflow.com/questions/7437 ... ding-first

Use it like this:
...
put (the path to the PDF on the device) into tURL
put "http://docs.google.com/gview?embedded=true&url=" before tURL
mobileControlSet "webPage","URL",tURL
...
I do not develop for ANDROID (yet) so I cannot test this.


Best

Klaus

Re: Display PDF in android device

Posted: Wed Dec 04, 2013 4:28 am
by JackD
Thanks Klaus,

"put "http://docs.google.com/gview?embedded=true&url=" before tURL" really does work. It's a bit clunky but the pdf opens and you can zoom in to read it.

How did we ever make progress before we had the internet and forums like this?

Re: Display PDF in android device

Posted: Wed Dec 04, 2013 12:48 pm
by Klaus
Hi Jack,
JackD wrote:How did we ever make progress before we had the internet and forums like this?
well, I did!
Maybe thats why I am so "fit" in Livecode, I had to learn it the hard way with try an error in my early days without internet! 8)

That's why I really get angry about people posting here but don't bother to take a short look into the dictionary but start to waste our time right way!
Not you, don't get me wrong! :)


Best

Klaus

Re: Display PDF in android device

Posted: Thu Mar 06, 2014 4:33 am
by joel.epsteinBUS31vi
Hi all -

Once again, I'm sure I'm missing something fundamentally obvious and simple. Unfortunately, I'm not seeing where I've gone astray and I'd appreciate any advice you may have.

I am trying to display a PDF in a browser on an Android device. I've made sure to put the appropriate file in the "copy files" pane of the standalone settings. But when I use this code:

Code: Select all

mobileControlCreate "browser"
put the result into browserID
mobileControlSet browserID, "rect", the rect of graphic "pdfRect"
mobileControlSet browserID, "visible", "true"
         
put specialFolderPath("engine") & "/pdfs/side-effects.pdf" into theURL
put "http://docs.google.com/gview?embedded=true&url=" before theURL
replace space with "%20" in theURL
         
mobileControlSet browserID, "url", theURL
the browser window appears, but is blank. If I change the last line with an actual URL, the URL appears correctly. So I'm fairly sure I have the control set up correctly.

When I add the line: answer theURL, I get this as a result:

Code: Select all

http://docs.google.com/gview?embedded=true&url=/data/app/com.projectiveart.sgd-1.apk/pdfs/side-effects.pdf
I'm not sure what that "-1" before the .apk is doing there. When I intentionally remove the "-1", the browser window is still blank.

So... That's where I'm at. I think I may be close. Sure would appreciate a final nudge in the right direction.

Thanks so much.

Joel

Re: Display PDF in android device

Posted: Thu Mar 06, 2014 6:29 am
by Simon
Hi Joel,
In reading the google docs, I don't think it can be a local file.
You will have to upload the file to a server and use it's URL.

Simon

Re: Display PDF in android device

Posted: Thu Mar 06, 2014 2:03 pm
by joel.epsteinBUS31vi
Hi Simon -

Thanks so much for the speedy response.

So is it correct to say that - given the limitations of the Android platform - there is no way to display an on-board PDF directly within LiveCode?

I appreciate your help.

Joel

Re: Display PDF in android device

Posted: Thu Mar 06, 2014 11:25 pm
by Simon
Hi Joel,
I can't say for sure that you can't, but I haven't seen a way.
You could export the pdf to images, if you had Adobe Acrobat.

Simon

Re: Display PDF in android device

Posted: Thu May 07, 2015 7:21 pm
by SparkOut
Is this still the case? Does anyone know how to open a pdf that has been stored as a local file on the android device?

Re: Display PDF in android device

Posted: Fri May 08, 2015 5:15 am
by josepxavier
I hope you do well

launch URL "file:/mnt/sdcard/formularios/preciario.pdf"

You need a viewer like Adobe Reader

Re: Display PDF in android device

Posted: Fri May 08, 2015 7:50 am
by SparkOut
This doesn't work though, when the file is bundled with the standalone app, the specialFolderPath("documents") is not accessible by the Adobe or 3rd party application. Is there a consistent location that we can copy the file to on different devices, which can be accessed by the 3rd party reader?

Re: Display PDF in android device

Posted: Tue May 12, 2015 1:39 am
by MaxV
As josepxavier said /mnt/sdcard/ is a public folder where any app can access.

Re: Display PDF in android device

Posted: Tue May 12, 2015 2:00 am
by Simon
As josepxavier said /mnt/sdcard/ is a public folder where any app can access.
Well I had always hoped that would be a constant but looking at my Galaxy S4 it's now
/storage/extSdCard/

Simon