Display PDF in android device
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Display PDF in android device
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
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
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Display PDF in android device
Hello Terry,
Android browser does not support .pdf viewing.
Simon
Android browser does not support .pdf viewing.
You have it right...it cannot work in android device
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Display PDF in android device
Any other way to display a PDF in Android?
Re: Display PDF in android device
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
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
-
- Livecode Opensource Backer
- Posts: 28
- Joined: Sat Mar 14, 2009 3:17 am
- Location: Olympia, WA USA
Re: Display PDF in android device
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?
"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?
27" iMac, OS X 10.13
iPad 3, iPad Pro, iPhone 4s, iPhone 6, LG Optimus L9 phone, Samsung Galaxy Camera
LiveCode 8.1.9
iPad 3, iPad Pro, iPhone 4s, iPhone 6, LG Optimus L9 phone, Samsung Galaxy Camera
LiveCode 8.1.9
Re: Display PDF in android device
Hi Jack,
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!
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
well, I did!JackD wrote:How did we ever make progress before we had the internet and forums like this?
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!
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
-
- Posts: 135
- Joined: Thu Sep 13, 2012 10:25 pm
Re: Display PDF in android device
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:
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:
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
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
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
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
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Display PDF in android device
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
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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 135
- Joined: Thu Sep 13, 2012 10:25 pm
Re: Display PDF in android device
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
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
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Display PDF in android device
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
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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Display PDF in android device
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?
-
- Posts: 6
- Joined: Wed Oct 08, 2014 6:12 pm
Re: Display PDF in android device
I hope you do well
launch URL "file:/mnt/sdcard/formularios/preciario.pdf"
You need a viewer like Adobe Reader
launch URL "file:/mnt/sdcard/formularios/preciario.pdf"
You need a viewer like Adobe Reader
Re: Display PDF in android device
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
As josepxavier said /mnt/sdcard/ is a public folder where any app can access.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Display PDF in android device
Well I had always hoped that would be a constant but looking at my Galaxy S4 it's nowAs josepxavier said /mnt/sdcard/ is a public folder where any app can access.
/storage/extSdCard/
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!