Page 1 of 1

Open document

Posted: Sat Feb 11, 2012 7:39 pm
by Polo
Hi,

I want my program to open a PDF document, using the default program available on the OS.
I'm unsure on how to do that, with cross platform in mind.
Anybody has an idea?

Re: Open document

Posted: Sat Feb 11, 2012 7:58 pm
by ts-soft

Code: Select all

RunProgram("mypdf.pdf")

Re: Open document

Posted: Sat Feb 11, 2012 8:18 pm
by Polo
ts-soft wrote:

Code: Select all

RunProgram("mypdf.pdf")
Thanks, but it doesn't work (at least not on OSX).

Re: Open document

Posted: Sat Feb 11, 2012 10:25 pm
by jesperbrannmark
Try this

Code: Select all

CompilerIf #PB_Compiler_OS=#PB_OS_MacOS
  a.s="tell application "+Chr(34)+"Preview"+Chr(34)+#LF$
  a.s+"activate"+#LF$
  a.s+"open "+Chr(34)+"/absolute/path/To/file/my file.pdf"+Chr(34)+#LF$
  a.s+"End tell"+#LF$
  COCOA_AppleScript(a.s)
CompilerEndIf
Take advantage of applescript.

Re: Open document

Posted: Sat Feb 11, 2012 11:28 pm
by Polo
Thanks, how do I use CocoaScript with PB?

Re: Open document

Posted: Sun Feb 12, 2012 1:58 am
by Polo
Found the solution for OSX, if that can help somebody :)

RunProgram("open", doc.pdf, "", #PB_Program_Open)