Open PDf inside of rev?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

Open PDf inside of rev?

Post by TodayIsTheDay » Sun Oct 04, 2009 8:56 pm

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!

espais
Posts: 14
Joined: Thu Jun 22, 2006 12:16 am

Post by espais » Sun Oct 04, 2009 10:15 pm

Hi,

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

Salut,
Josep

TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

Post by TodayIsTheDay » Mon Oct 05, 2009 1:09 am

But do most people just take for granted their end users have some sort of pdf reader installed on their machines?

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Mon Oct 05, 2009 6:11 am

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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

Post by TodayIsTheDay » Mon Oct 05, 2009 2:10 pm

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?)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Mon Oct 05, 2009 3:23 pm

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)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

Post by TodayIsTheDay » Mon Oct 05, 2009 5:59 pm

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....

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Mon Oct 05, 2009 7:47 pm

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
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply