View Full Version : open a .PDF file in PDF reader
Jul 21, 2009, 12:12 AM
In cocoa how can I open a .PDF file in a PDF reader?
Jul 21, 2009, 12:15 AM
Launch Services (http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/Reference/reference.html)
The terminal app "open" will do the same, but it's probably "cleaner" to use launch services.
Jul 21, 2009, 12:22 AM
Thank you Lee for your quick reply ... but I think you did not get me .. I want something like this:
// code for opening a .PDF file in PDF reader
I don't know which code to use :confused:
Jul 21, 2009, 12:54 AM
Let's say you have a fixed path:
struct FSRef myRef;
OSStatus myStatus = FSPathMakeRef("/my/path/to/thisPDF.pdf",&myRef,NULL);
myStatus = LSOpenFSRef(&myRef,NULL);
The NULL values are optional parameters that I didn't use to keep it simple. The one in FSPathMakeRef would be a Boolean * that would contain whether or not the path is a directory on return. The NULL in LSOpenFSRef would be a FSRef * that would contain the opening program if you needed to know on return.
Jul 21, 2009, 01:25 AM
Just to clarify, are you asking how to open a .pdf file with the user's default application for .pdf's? or are you asking about how to implement PDFView and/or PDFKit into your app?
Jul 21, 2009, 02:00 AM
how to open a .pdf file with the user's default application for .pdf's