Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* from scriptbuilders. cheap way to utilize quartz on osx for pdf pagecount */
- #import <Foundation/Foundation.h>
- #import <Quartz/Quartz.h>
- int main (int argc, const char * argv[]) {
- if (argc != 2){
- printf("Usage: PDFPageCounter path\n");
- return 1;
- }
- int returnValue = 0;
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- NSString *filePath = [[[NSProcessInfo processInfo] arguments] objectAtIndex:1];
- NSURL *docURL = [[NSURL alloc] initFileURLWithPath:filePath];
- PDFDocument *doc = [[PDFDocument alloc] initWithURL:docURL];
- if (doc) {
- printf("%i\n", [doc pageCount]);
- [doc release];
- }
- else {
- printf("no valid PDF document\n");
- returnValue = 2;
- }
- [docURL release];
- [pool drain];
- return returnValue;
- }
Add Comment
Please, Sign In to add comment