Page 1 of 1

Help with displaying content(pdf) inside revbrowser please

Posted: Thu May 26, 2016 12:02 am
by chasecon
Hey, I've been trying some tutorials online to display links/files/PDFs without using an external program. They have been saying to use revBrowser and the google button works at loading google inside the stack, but the search for pdf button tries to open it in firefox and not inside the stack. The tutorials all say (I've looked at many) that this should work. Any idea what I'm doing wrong?


The app is just one stack with an image thing and two buttons

here is the stack code

Code: Select all

        global myBrowser

        on browserOpen
                if myBrowser is empty then
                     put revBrowserOpen(the windowid of this stack,"") into myBrowser
                end if
                revBrowserSet myBrowser, "showborder","true"
                revBrowserSet myBrowser, "visible","true"
                revBrowserSet myBrowser, "rect",rect of image "bwin"
        end browserOpen

        on browserClose
                revBrowserClose myBrowser
                put empty into myBrowser
end browserClose

on browserSetURL pURL

## Set the url to be displayed to the given url

revBrowserSet myBrowser, "url", pURL

end browserSetURL
google button

Code: Select all

             global myBrowser

               on mouseUp
                    browserOpen
                    revBrowserSet myBrowser , "url", " google (.)  com"
               end mouseUp
pdf search button

Code: Select all

                    global myBrowser

                   on mouseUp
                             browserOpen

                             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
                                    --revBrowserSet myBrowser , "url", tFile
                                    browserSetURL tFile
                            end if
                    end mouseUp

Re: Help with displaying content(pdf) inside revbrowser plea

Posted: Thu May 26, 2016 11:34 am
by Klaus
Hi chasecon,

1. welcome to the forum! :D

2. You need to tell the browser that you want to open a LOCAL file like this:

Code: Select all

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

Klaus

Re: Help with displaying content(pdf) inside revbrowser plea

Posted: Thu May 26, 2016 8:48 pm
by chasecon
Klaus wrote:Hi chasecon,

1. welcome to the forum! :D

2. You need to tell the browser that you want to open a LOCAL file like this:

Code: Select all

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

Klaus
thanks for the reply! I have tried adding that to the code, but it still is trying to open the pdf in firefox externally. This is driving me insane!!

Re: Help with displaying content(pdf) inside revbrowser plea

Posted: Fri May 27, 2016 1:38 pm
by Klaus
Hi chasecon,
...but it still is trying to open the pdf in firefox externally.
Too funky!? :shock:

Hmm, no idea what is going on there...

But I see that you only check if "myBrowser" is not empty, you should check if "myBrowser" is a NUMBER!
If an error occurs that variable will contain that error and is also not empty!

And add a little check after trying to open the PDF file, maybe that will gived a hint:

Code: Select all

on browserSetURL pURL
   ## Set the url to be displayed to the given url
   revBrowserSet myBrowser, "url", pURL

   if the result <> EMPTY then
      answer "Error:" && the result
  end if
end browserSetURL
Best
Klaus