Page 1 of 1

Open documents using iPad Quick Look?

Posted: Fri Dec 10, 2010 4:47 pm
by Simon
Has anyone figured out how to open, say a pdf, using iPads Quick Look? I mean via LC.
This would be great because Quick Look handles many types of files.

Thanks,
Simon

Re: Open documents using iPad Quick Look?

Posted: Tue Nov 15, 2011 5:01 pm
by maarten.koopmans
Same question, anyone done this via, say, UIWebView ?

Re: Open documents using iPad Quick Look?

Posted: Tue Nov 15, 2011 5:39 pm
by Simon
Hi Maarten,
That is what I ended up using. Just put the docs in a browser.

Simon

Re: Open documents using iPad Quick Look?

Posted: Tue Nov 15, 2011 7:14 pm
by maarten.koopmans
I tried that, but doesn;t work. Can you send me (or PM me) a sample? I would be most grateful.

As url I am trying file:docs\test.pdf, where test.pdf is in the engine\docs directory

Re: Open documents using iPad Quick Look?

Posted: Wed Nov 16, 2011 1:20 am
by Simon
I'd use the documents folder:
specialFolderPath("documents")
I think the entire URL looks something like this:
iphoneControlSet sBrowserID, "url", "File://" & (specialFolderPath("documents") & "test.pdf")

Simon

Re: Open documents using iPad Quick Look?

Posted: Wed Nov 16, 2011 8:22 am
by Jellicle
I use this:

put (specialFolderPath("Documents") & "/lunch.pdf") into theUrl
replace " " with "%20" in theUrl -- don't ask, just do it :)
iphoneControlSet browserID, "url", theUrl

Gerry

Re: Open documents using iPad Quick Look?

Posted: Wed Nov 16, 2011 8:23 am
by Jellicle
maarten.koopmans wrote:As url I am trying file:docs\test.pdf, where test.pdf is in the engine\docs directory
"\" ? Is that your problem? It should be "/".

Gerry

Re: Open documents using iPad Quick Look?

Posted: Wed Nov 16, 2011 2:48 pm
by Klaus
Dag maarten,

you should really take a look at the "iOS Release Notes" (menu: Help)!
That is the only documentation we have for iOS.
maarten.koopmans wrote:file:docs\test.pdf
This is definitively NOT a valid path in iOS!
And LiveCode ALWAYS uses a SLASH as a path delimiter, since it has its roots in Unix.
maarten.koopmans wrote:... is in the engine\docs directory
So you need to do this like in Jellicle's example::

Code: Select all

...
put specialfolderpath("engine") & "/" & docs/test.pdf" into tUrl
replace " " with "%20" in theUrl
## NO spaces allowed in internet URLs!!!
## Internet browser do this behind the scenes when we enter URLs with SPACES!
iphoneControlSet browserID, "url", theUrl
...
Best

Klaus

Re: Open documents using iPad Quick Look?

Posted: Wed Nov 16, 2011 3:00 pm
by Simon
Hi Klaus,
Is this where we use URLEncode?
But with, replace "+"with "%20", to get all characters?

Simon

Re: Open documents using iPad Quick Look?

Posted: Wed Nov 16, 2011 3:19 pm
by Klaus
Hi Simon,

no urlencoding!
URLs are a special case where we "only" need to replace SPACE with "%20".

Don't ask me why, I didn't invent it :D


Best

Klaus

Re: Open documents using iPad Quick Look?

Posted: Thu Nov 17, 2011 8:36 am
by FireWorx
The first handler below works to create the browser and load a pdf with the file name "APT600_30.PDF" in a folder titled "ALSFD" in the documents folder. The statementbelow : iphoneControlSet sBrowserId, "autoFit", "true" is important. The second handler loads a PDF once the browser has been created. What you don't want is a bunch of browser instances opened with iphoneControlCreate "browser" command and the sBrowserId global variable overwritten each time. Then when you go to another card the browser window follows you to that card. I'd post my stack but the 256k limit won't allow me to load even two pdf's. lame.

here is the code.

global sBrowserId ## the number of the browser instance kept I'm memory

on openMyBrowserForBusiness ## this one creates the browser with the iphoneControlCreate "browser" command
if the environment is not "mobile" then exit openMyBrowserForBusiness ## only works in the tester or on an IOS Ipad
put "APT600_S30" into tMyPdfChoice ## one of the PDF file names in the "ALSFD" folder
put "file:///" & specialfolderpath("documents") & "/ALSFD/" & tMyPdfChoice & ".pdf" into tLocalPDF
replace " " with "%20" in tLocalPDF ## replaces blank spaces in the url
iphoneControlCreate "browser" ## creates a browser instance
   put the result into sBrowserId ## the number of the instance kept in memory
set the rect of group "Browser" to 0,120, the width of this card, the height of this card ## set the rect of the browser
iphoneControlSet sBrowserId, "rect" , the rect of group "Browser"
   iphoneControlSet sBrowserId, "visible" , "true"
   iphoneControlSet sBrowserId, "autoFit", "true"
   iphoneControlSet sBrowserId, "url", tLocalPDF
end openMyBrowserForBusiness


on ReloadWhenBrowserIsOpen ## sent from tthe left, right, up, down buttons to navigate
if the environment is not "mobile" then exit ReloadWhenBrowserIsOpen
put "APT600_Q30" into tMyPdfChoice
put specialfolderpath("documents") & "/ALSFD/" & tMyPdfChoice & ".pdf" into tLocalPDF
 if there is not a file tLocalPDF then
answer "page" && tMyPdfChoice && "is either not a valid file address or there was a problem loading it."
exit ReloadWhenBrowserIsOpen
end if
put "file:///" & specialfolderpath("documents") & "/ALSFD/" & tMyPdfChoice & ".pdf" into tLocalPDF
replace " " with "%20" in tLocalPDF
iphoneControlSet sBrowserId, "rect" , the rect of group "Browser"
   iphoneControlSet sBrowserId, "visible" , "true"
   iphoneControlSet sBrowserId, "autoFit", "true"
   iphoneControlSet sBrowserId, "url", tLocalPDF
end ReloadWhenBrowserIsOpen

on closeCard
   if the environment is not "mobile" then
      exit closeCard
   end if
    # destroy the browser we created 
   iphoneControlDelete sBrowserId
end closeCard