Guest User

Untitled

a guest
May 26th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. /* from scriptbuilders. cheap way to utilize quartz on osx for pdf pagecount */
  2.  
  3. #import <Foundation/Foundation.h>
  4. #import <Quartz/Quartz.h>
  5.  
  6. int main (int argc, const char * argv[]) {
  7.  
  8. if (argc != 2){
  9. printf("Usage: PDFPageCounter path\n");
  10. return 1;
  11. }
  12. int returnValue = 0;
  13. NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  14. NSString *filePath = [[[NSProcessInfo processInfo] arguments] objectAtIndex:1];
  15. NSURL *docURL = [[NSURL alloc] initFileURLWithPath:filePath];
  16. PDFDocument *doc = [[PDFDocument alloc] initWithURL:docURL];
  17. if (doc) {
  18. printf("%i\n", [doc pageCount]);
  19. [doc release];
  20. }
  21. else {
  22. printf("no valid PDF document\n");
  23. returnValue = 2;
  24. }
  25. [docURL release];
  26. [pool drain];
  27. return returnValue;
  28. }
Add Comment
Please, Sign In to add comment