-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcliWrapper.m
70 lines (55 loc) · 1.79 KB
/
cliWrapper.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// cliWrapper.m
// pdfimages
//
// Created by Pim Snel on 05-07-11.
// Copyright 2011 Lingewoud B.V. All rights reserved.
//
#import "cliWrapper.h"
int c_main(int argc, char *argv[]);
@implementation cliWrapper
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
-(void)cw_printUsage
{
printf("PDF-Images for Cocoa with cli\n");
printf("Usage: pdfimages [options]\n");
printf("\n");
printf("Without options the drag'n'drop GUI is started.\n");
printf("\n");
printf(" -h : print usage information\n");
printf(" -i <filePath> : path to PDF to use as input\n");
printf(" -j : write JPEG images as JPEG files\n");
printf(" -p : run in GUI despite other options\n");
printf("\n");
}
-(void)cw_runPdfimages: (NSString *) argIn :(BOOL) useJpeg {
NSLog(@"run cli version with file: %@", argIn);
NSString *dir = [argIn stringByDeletingLastPathComponent];
[[NSFileManager defaultManager] changeCurrentDirectoryPath:dir];
char buffer[1024];
strlcpy(buffer, [[argIn lastPathComponent] fileSystemRepresentation], sizeof(buffer));
char prefix[1024];
strlcpy(prefix, [[[argIn lastPathComponent] stringByDeletingPathExtension] fileSystemRepresentation], sizeof(prefix));
if (useJpeg)
{
char *argv[] = { "pdfimages", "-q","-j", buffer, prefix };
c_main(sizeof(argv) / sizeof(char *), argv);
}
else
{
char *argv[] = { "pdfimages", "-q", buffer, prefix };
c_main(sizeof(argv) / sizeof(char *), argv);
}
}
@end