Open documents using iPad Quick Look?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Open documents using iPad Quick Look?

Post by Simon » Fri Dec 10, 2010 4:47 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

maarten.koopmans
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 20
Joined: Sun Dec 28, 2008 3:26 pm

Re: Open documents using iPad Quick Look?

Post by maarten.koopmans » Tue Nov 15, 2011 5:01 pm

Same question, anyone done this via, say, UIWebView ?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Open documents using iPad Quick Look?

Post by Simon » Tue Nov 15, 2011 5:39 pm

Hi Maarten,
That is what I ended up using. Just put the docs in a browser.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

maarten.koopmans
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 20
Joined: Sun Dec 28, 2008 3:26 pm

Re: Open documents using iPad Quick Look?

Post by maarten.koopmans » Tue Nov 15, 2011 7:14 pm

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Open documents using iPad Quick Look?

Post by Simon » Wed Nov 16, 2011 1:20 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Open documents using iPad Quick Look?

Post by Jellicle » Wed Nov 16, 2011 8:22 am

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
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Open documents using iPad Quick Look?

Post by Jellicle » Wed Nov 16, 2011 8:23 am

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
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Open documents using iPad Quick Look?

Post by Klaus » Wed Nov 16, 2011 2:48 pm

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Open documents using iPad Quick Look?

Post by Simon » Wed Nov 16, 2011 3:00 pm

Hi Klaus,
Is this where we use URLEncode?
But with, replace "+"with "%20", to get all characters?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Open documents using iPad Quick Look?

Post by Klaus » Wed Nov 16, 2011 3:19 pm

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

FireWorx
Posts: 362
Joined: Wed Sep 07, 2011 9:39 pm

Re: Open documents using iPad Quick Look?

Post by FireWorx » Thu Nov 17, 2011 8:36 am

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

Post Reply