Created
May 23, 2010 11:52
-
-
Save atr000/410870 to your computer and use it in GitHub Desktop.
pdf page counter using quartz in objc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment