X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2Fpdftopbm.cc;h=549b57b4becf6bab9c21b2a6201b5d6a2863836f;hb=7aac8dc8533347e21311b15186e0af82f1b22fd6;hp=6cfe83059f9918af01ec5256516786973d713705;hpb=50e9d31c05e9ca11ad43cc570556094782c1b956;p=evince.git diff --git a/pdf/xpdf/pdftopbm.cc b/pdf/xpdf/pdftopbm.cc index 6cfe8305..549b57b4 100644 --- a/pdf/xpdf/pdftopbm.cc +++ b/pdf/xpdf/pdftopbm.cc @@ -29,7 +29,8 @@ static int firstPage = 1; static int lastPage = 0; static int resolution = 150; -GBool printCommands = gFalse; +static char userPassword[33] = ""; +static GBool printVersion = gFalse; static GBool printHelp = gFalse; static ArgDesc argDesc[] = { @@ -39,8 +40,12 @@ static ArgDesc argDesc[] = { "last page to print"}, {"-r", argInt, &resolution, 0, "resolution, in DPI (default is 150)"}, + {"-upw", argString, userPassword, sizeof(userPassword), + "user password (for encrypted files)"}, {"-q", argFlag, &errQuiet, 0, "don't print any messages or errors"}, + {"-v", argFlag, &printVersion, 0, + "print copyright and version info"}, {"-h", argFlag, &printHelp, 0, "print usage information"}, {"-help", argFlag, &printHelp, 0, @@ -52,15 +57,18 @@ int main(int argc, char *argv[]) { PDFDoc *doc; GString *fileName; char *pbmRoot; + GString *userPW; PBMOutputDev *pbmOut; GBool ok; // parse args ok = parseArgs(argDesc, &argc, argv); - if (!ok || argc != 3 || printHelp) { + if (!ok || argc != 3 || printVersion || printHelp) { fprintf(stderr, "pdftopbm version %s\n", xpdfVersion); fprintf(stderr, "%s\n", xpdfCopyright); - printUsage("pdftopbm", " ", argDesc); + if (!printVersion) { + printUsage("pdftopbm", " ", argDesc); + } exit(1); } fileName = new GString(argv[1]); @@ -74,9 +82,18 @@ int main(int argc, char *argv[]) { // open PDF file xref = NULL; - doc = new PDFDoc(fileName); - if (!doc->isOk()) - exit(1); + if (userPassword[0]) { + userPW = new GString(userPassword); + } else { + userPW = NULL; + } + doc = new PDFDoc(fileName, userPW); + if (userPW) { + delete userPW; + } + if (!doc->isOk()) { + goto err; + } // get page range if (firstPage < 1) @@ -87,10 +104,11 @@ int main(int argc, char *argv[]) { // write PBM files rgbCubeSize = 1; pbmOut = PBMOutputDev::makePBMOutputDev(NULL, pbmRoot); - doc->displayPages(pbmOut, firstPage, lastPage, resolution, 0); - delete pbmOut; + doc->displayPages(pbmOut, firstPage, lastPage, resolution, 0, gFalse); + PBMOutputDev::killPBMOutputDev(pbmOut); // clean up + err: delete doc; freeParams();