1 //========================================================================
5 // Copyright 1998 Derek B. Noonburg
7 //========================================================================
13 #include "parseargs.h"
24 #include "ImageOutputDev.h"
29 static int firstPage = 1;
30 static int lastPage = 0;
31 static GBool dumpJPEG = gFalse;
32 GBool printCommands = gFalse;
33 static GBool printHelp = gFalse;
35 static ArgDesc argDesc[] = {
36 {"-f", argInt, &firstPage, 0,
37 "first page to convert"},
38 {"-l", argInt, &lastPage, 0,
39 "last page to convert"},
40 {"-j", argFlag, &dumpJPEG, 0,
41 "write JPEG images as JPEG files"},
42 {"-q", argFlag, &errQuiet, 0,
43 "don't print any messages or errors"},
44 {"-h", argFlag, &printHelp, 0,
45 "print usage information"},
46 {"-help", argFlag, &printHelp, 0,
47 "print usage information"},
51 int main(int argc, char *argv[]) {
55 ImageOutputDev *imgOut;
59 ok = parseArgs(argDesc, &argc, argv);
60 if (!ok || argc != 3 || printHelp) {
61 fprintf(stderr, "pdfimages version %s\n", xpdfVersion);
62 fprintf(stderr, "%s\n", xpdfCopyright);
63 printUsage("pdfimages", "<PDF-file> <image-root>", argDesc);
66 fileName = new GString(argv[1]);
73 initParams(xpdfConfigFile);
77 doc = new PDFDoc(fileName);
82 // check for copy permission
83 if (!doc->okToCopy()) {
84 error(-1, "Copying of images from this document is not allowed.");
91 if (lastPage < 1 || lastPage > doc->getNumPages())
92 lastPage = doc->getNumPages();
95 imgOut = new ImageOutputDev(imgRoot, dumpJPEG);
97 doc->displayPages(imgOut, firstPage, lastPage, 72, 0);
106 // check for memory leaks
107 Object::memCheck(stderr);