Displaying the PDF within a Rev stack

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
shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Displaying the PDF within a Rev stack

Post by shalu » Mon Sep 28, 2015 12:08 pm

Hi All,

I am using Linux system(64-bit Linux) and LiveCode version 8, My objective is Displaying the PDF within a Rev stack, so that I am use the following code

Code: Select all


global sBrowserId
on openCard
    browserOpen
end openCard

on browserOpen
    put the windowid of this stack into tWinID
    put revBrowserOpen(tWinID,"") into sBrowserId
    revBrowserSet sBrowserId, "showborder","true"
    revBrowserSet sBrowserId, "rect",rect of image "browser image"
end browserOpen
on browserClose
    revBrowserClose sBrowserId
end browserClose 


global sBrowserId

on mouseUp
    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
        browserSetURL tFile
    end if
end mouseUp

the browserSetURL handler is implemented in the card script

on browserSetURL pURL
      answer pURL
    revBrowserSet sBrowserId, "url", pURL
end browserSetURL

while executing the code I got the following error, How I solve this problem? :roll: :cry:
card "browserOpen": execution error at line n/a (External handler: exception) near "creation failed"
button "Browse": execution error at line n/a (External handler: exception) near "unknown browser id"
Thanks
Shalu
--
Thanks
Shalu S

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Displaying the PDF within a Rev stack

Post by MaxV » Tue Sep 29, 2015 1:55 pm

Hi Shalu,
first of all revBrowser doesn't work on linux, just on windows and Mac.
Probably you misunderstood the examplel, because on win or mac you should:
  • put an image in the card, this image can be empty
  • name it "browser image"
  • put this code in the card:

    Code: Select all

    on openCard
        browserOpen
    end openCard
    
    on browserOpen
        put the windowid of this stack into tWinID
        put revBrowserOpen(tWinID,"") into sBrowserId
        set the bID of me to sBrowserId  #custom property
        revBrowserSet sBrowserId, "showborder","true"
        revBrowserSet sBrowserId, "rect",rect of image "browser image"
    end browserOpen
    
    on browserClose
        put the bID of this card into sBrowserId #custom property
       revBrowserClose sBrowserId
    end browserClose
    
    on closecard
      browserClose
    end closecard
  • put a button in the card
  • put this code in the button:

    Code: Select all

     on mouseUp
        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
            browserSetURL tFile
        end if
    end mouseUp
    
    on browserSetURL pURL
       answer pURL
       put the bID of this card into sBrowserId #custom property
       revBrowserSet sBrowserId, "url", ("binfile://" & pURL)
    end browserSetURL
On linux, to see a PDF, put a button in the card and put this code in the button:

Code: Select all

 on mouseUp
    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
        put  shell("evince " & tFile)
    end if
end mouseUp
Usually evince is default PDF viewer on Linux.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply