revBrowserOpen Local PDF File

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
JLGDBMD
Posts: 12
Joined: Wed Jul 04, 2012 6:13 pm

revBrowserOpen Local PDF File

Post by JLGDBMD » Sat Sep 08, 2012 7:16 pm

Not sure why the script below does not display the selected PDF File
from my Mac HD. I checked the filepath in the variable tFile and it looks correct.
If I feed tFile a web address instead, then the web page displays without issue
in the rev browser. Thanks - Jorge

on MouseUP
local tBrowserId
local tFile

   answer file "Please choose the file you would like to display" with type "PDF document|pdf|PDF"
   
if it is not empty then
     put it into tFile
  end if  

put revBrowserOpen(the windowId of this stack,tFile) into tBrowserId
if tBrowserId is not an integer then
answer "Failed to open browser"
exit mouseUp
end if
   
revBrowserSet tBrowserId, "showborder","true"
    
revBrowserSet tBrowserId, "rect", "116,14,1198,660"
end mouseUp

JLGDBMD
Posts: 12
Joined: Wed Jul 04, 2012 6:13 pm

Re: revBrowserOpen Local PDF File

Post by JLGDBMD » Sat Sep 08, 2012 8:18 pm

I used the Safari browser to open the PDF files directly and noted that there were
no empty spaces in the filepath used by Safari. Instead there was a "%20" where
a space would normally be in the filepath.

So I added this line of script and it works -

replace space with "%20" in tFile    

So /Users/Documents/Some Folder/This Thing.PDF will not open in revBrowser but
/Users/Documents/Some%20Folder/This%20Thing.PDF will

Not sure why this is the case but at least it works. Any ideas?

Thanks. - Jorge

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

Re: revBrowserOpen Local PDF File

Post by Klaus » Sat Sep 08, 2012 9:47 pm

Hi Jorge,

yep, "replace SPACE with "%20" is the way to go :D
But you also need to add the "file" keyword to the url like this:
...
replace space with "%20" in tFile
put "file://" & tFile into tUrl
put revBrowserOpen(the windowId of this stack,tUrl) into tBrowserId
...

Best

Klaus

JLGDBMD
Posts: 12
Joined: Wed Jul 04, 2012 6:13 pm

Re: revBrowserOpen Local PDF File

Post by JLGDBMD » Sat Sep 08, 2012 11:18 pm

Got it.

Thanks for the follow-up Klaus.

Jorge

Post Reply