Page 1 of 1
Launch a PDF on iOS??
Posted: Mon Mar 25, 2013 7:29 pm
by edwardeddyus
I'm a web developer new to livecode and I'm trying to convert a web application to an iPad app that contains many PDF links. I've been using the following but I can't get it to work anyone know what I'm doing wrong? I have several videos playing using specialfolderpath("engine") and including them in the standalone application screen does it work the same for all documents such as pdfs?
Code: Select all
//On my card
command openpdfs pdffile
launch url "file://" & specialfolderpath("engine") & pdffile
end openpdfs
//On my buttons
on Mouseup
openpdfs "HY3780.pdf"
end Mouseup
Re: Launch a PDF on iOS??
Posted: Mon Mar 25, 2013 9:38 pm
by Simon
I think you are missing a slash:
on Mouseup
openpdfs "/HY3780.pdf"
end Mouseup
or after the special path
launch url "file://" & specialfolderpath("engine") & "/" & pdffile
Simon
Re: Launch a PDF on iOS??
Posted: Tue Mar 26, 2013 5:04 am
by Nakia
I use Monte's mergReader External...
Google mergExt
Re: Launch a PDF on iOS??
Posted: Tue Mar 26, 2013 11:35 am
by Klaus
Hi Edward,
1. welcome to the forum
2. ALWAYS put parens around concatenated pathnames (and concatenated names in general)!
...
launch url ("file://" & specialfolderpath("engine") & "/" & pdffile)
...
did I mention always?
If you don't, the engine will only interpret the FIRST part (before the &) as the (path)name, which does not work of course.
Best
Klaus
Re: Launch a PDF on iOS??
Posted: Tue Mar 26, 2013 3:37 pm
by edwardeddyus
Thank you all for the quick responses!
I added the extra slash and the prens and tried it on both the simulator and on the device and it still won't seem to work.
What else should I try?
Re: Launch a PDF on iOS??
Posted: Tue Mar 26, 2013 3:45 pm
by sturgis
Right after the launch command, you might put look to see what is in the result
If there was an error (like file not found or whatever) you'll be able to see it there.
Re: Launch a PDF on iOS??
Posted: Tue Mar 26, 2013 4:29 pm
by edwardeddyus
Ok that gives me "no association" but the device does have Acrobat installed on it?
Re: Launch a PDF on iOS??
Posted: Tue Mar 26, 2013 7:37 pm
by sturgis
I don't have an ios device to test on right now but my guess is that you can go into settings for acrobat reader on the device and set it as the default for .pdf file types. Might be in the reader app itself or might be in the settings elsewhere.
Out of curiosity though you might try this:
Code: Select all
launch url ("com.adobe.Adobe-Reader://" & & specialfolderpath("engine") & "/" & pdffile)
Let me know if it works. If it does its because it is using the adobe registered URL scheme so that IOS knows what to use to open the file. Of course if the file is STILL not registered as an association, or the scheme isn't there then it still won't work, but its worth a shot. I've read of folks being able to use this to get reader to open but that full support for the url scheme wasn't there yet. However, the stuff I read was old and may no longer apply. Worst case, there are other adobe readers out there that you CAN call using a URL scheme that fully support the URL scheme method.
Re: Launch a PDF on iOS??
Posted: Wed Mar 27, 2013 1:19 am
by endernafi
Alternative approach:
You can create a native browser instance,
and show the pdf file inside it.
Code: Select all
on mouseUp
openPdf "HY3780.pdf"
end mouseUp
on openPdf pPdfFile
put "theBrowser" into tBrowserName
if tBrowserName is among the lines of mobileControls() then mobileControlDelete tBrowserName
put the rect of button "theBrowserPlaceholder" into tRect
put (specialFolderPath("engine") & slash & pPdfFile) into tUrl
mobileControlCreate "browser", tBrowserName
mobileControlSet tBrowserName, "rect", tRect
mobileControlSet tBrowserName, "visible", true
mobileControlSet tBrowserName, "url", tUrl
mobileControlSet tBrowserName, "autoFit", true
end openPdf
Best,
~ Ender Nafi
Re: Launch a PDF on iOS??
Posted: Wed Mar 27, 2013 3:03 pm
by edwardeddyus
sturgis thanks I'll give that a try and let you know if it works
endernafi if sturgis's suggestion doesn't work I'll certainly give that a try it may be a bit cleaner in the end. One question though should:
Code: Select all
put (specialFolderPath("engine") & slash & pPdfFile) into tUrl
Actually be:
Code: Select all
put ("file://" & specialFolderPath("engine") & slash & pPdfFile) into tUrl
or will it work without the file reference?
Re: Launch a PDF on iOS??
Posted: Wed Mar 27, 2013 3:22 pm
by endernafi
Hi Edward,
I use it without "file://" and it works just fine with pdfs and local html files.
But, I did a quick test now and it seems that adding the "file://" prefix works, too.
One advantage of this method is, obviously, the user won't leave your app.
Best,
~ Ender Nafi
Re: Launch a PDF on iOS??
Posted: Thu Mar 28, 2013 8:22 pm
by edwardeddyus
Ender, your solutions worked!! Thank you and everyone else for the help.
Re: Launch a PDF on iOS??
Posted: Thu Mar 28, 2013 8:46 pm
by endernafi
Glad that it helped
Cheers,
~ Ender Nafi