Page 1 of 1

Open PDf inside of rev?

Posted: Sun Oct 04, 2009 8:56 pm
by TodayIsTheDay
What is the best way to open a pdf?

Do you have to check to see if they have acrobat, etc then open?

I was programming in another high level language that had a built in pdf reader so this was super easy...?
Is there any way to have this in Runrev?

Thanks!

Posted: Sun Oct 04, 2009 10:15 pm
by espais
Hi,

To open a PDF you can use the launch command or use revBrowser.

Salut,
Josep

Posted: Mon Oct 05, 2009 1:09 am
by TodayIsTheDay
But do most people just take for granted their end users have some sort of pdf reader installed on their machines?

Posted: Mon Oct 05, 2009 6:11 am
by Janschenkel
Well, MacOSX ships with Preview, a quite capable PDF reader among other things. Most Linux distributions ship with Xpdf, Evince or KPDF. And most Windows boxes I've come accross had Acrobat Reader installed.
You can always put a download link for Acrobat Reader right next to your own app's download, so they can fetch it from Adobe's website if needed.

Jan Schenkel.

Posted: Mon Oct 05, 2009 2:10 pm
by TodayIsTheDay
Then I won't sweat that part too much then.

Is the best way to add the pdf as you start to build the program?

How do you reference them with the launch command? (what would the file path be?)

Posted: Mon Oct 05, 2009 3:23 pm
by FourthWorld
The "launch url" command will launch a given URL or file path with the application currently registered with the OS to handle that type:

Code: Select all

answer file "Select a PDF File:" with type "PDF File|pdf"
if it is empty then exit to top
launch url ("file:"&it)

Posted: Mon Oct 05, 2009 5:59 pm
by TodayIsTheDay
hmmm. I've got to have this super, super simple. Last time we had an app where people had to do anything but click a button and the pdf opened we had refunds...

I'm still not clear on what the path would be to the pdf if it was embedded into the program?

I'm pretty sure I'm going to have to use an installer to add some of the other files to a folder. I can just add the pdf to that folder as well maybe....

Posted: Mon Oct 05, 2009 7:47 pm
by FourthWorld
The key is to build a path to the file based on its relative position to your executable, using something like this:

Code: Select all

on mouseUp
  launch url PDFPath()
end mouseUp

-- Somewhere in your centralized code:

-- This function assumes you have a folder containing your PDFs
-- named "PDF Folder" in the same directory as your app:
function PDFPath
   return AppPath()&"PDF Folder/MyPDF.pdf"
end PDFPath

-- This function returns the path to the executable on Windows
-- and the .app bundle on OS X:
function AppPath
  put the filename of this stack into tPath
  set the itemdel to "/"
  If (IsOSX()) then
    get offset(".app/Contents/MacOS/", tPath)
    if it > 0 then -- 2.4.3 or later
      delete char it to len(tPath) of tPath
    end if
  end if
  delete last item of tPath
  return tPath &"/"
end AppPath

function IsOSX
  if the platform is not "MacOS" then return false
  get the systemversion
  set the itemdel to "."
  if item 1 of it >= 10 then return true
  return false
end IsOSX