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 {"-h", argFlag, &printHelp, 0,
43 "print usage information"},
44 {"-help", argFlag, &printHelp, 0,
45 "print usage information"},
49 int main(int argc, char *argv[]) {
53 ImageOutputDev *imgOut;
57 ok = parseArgs(argDesc, &argc, argv);
58 if (!ok || argc != 3 || printHelp) {
59 fprintf(stderr, "pdfimages version %s\n", xpdfVersion);
60 fprintf(stderr, "%s\n", xpdfCopyright);
61 printUsage("pdfimages", "<PDF-file> <image-root>", argDesc);
64 fileName = new GString(argv[1]);
71 initParams(xpdfConfigFile);
75 doc = new PDFDoc(fileName);
82 if (lastPage < 1 || lastPage > doc->getNumPages())
83 lastPage = doc->getNumPages();
86 imgOut = new ImageOutputDev(imgRoot, dumpJPEG);
88 doc->displayPages(imgOut, firstPage, lastPage, 72, 0);
95 // check for memory leaks
96 Object::memCheck(errFile);