 |  |
 |
|
Developer's API
Developers can write simple code to convert EPS and PS files to PDF using the PStill engine. Here's How:
1. Include the following Protocol as a .h file:
@protocol PStillVended
// 0 = success anything else = failure
// caller's responsibility to make sure outputFile is writeable and not existing!
- (int)convertFile:(NSString *)inputFile toPDFFile:(NSString *)outputFile deleteInput:(BOOL)deleteInput;
// when licensing is done, this will return YES, otherwise NO
- (BOOL)applicationReadyForInput;
@end
2. Call the Engine
This is sample calling code which checks to be sure PStill is launched, the licensing is finished and it's ready to go. If the conversion is successful, "0" is returned:
// first, launch app if it is not launched:
if (![[NSWorkspace sharedWorkspace] launchApplication:@"PStill"]) {
NSLog(@"Exporting PDF requires PStill for Mac OS X by Stone Design and Frank Siegert. Visit www.stone.com to download and full information.");
}
// let's talk to PStill:
theProxy = [NSConnection rootProxyForConnectionWithRegisteredName:PStillFilterServer host:nil];
// if we find it, continue:
if (theProxy != nil) {
// if PStill's not launched, wait until it's licensed
while(![theProxy applicationReadyForInput])
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
// teach the proxy the methods that are understood:
[theProxy setProtocolForProxy:@protocol(PStillVended)];
// convert our file
if ([theProxy convertFile:inputFile toPDFFile:outputFile deleteInput:NO] == 0) {
// YOUR OUTPUT FILE CONTAINS THE PDF!
}
}
NOTE: Obviously, you must have a licensed version of PStill for this to work! If you just want to test PStill in demo mode, remove the "while (![theProxy applicationReadyForInput]) statement. |
|