--- poppler-0.15.2/utils/pdftoppm.cc- 2010-10-30 01:40:07.000000000 +0200 +++ poppler-0.15.2/utils/pdftoppm.cc 2010-12-01 16:20:45.083763878 +0100 @@ -53,6 +53,7 @@ static int lastPage = 0; static GBool printOnlyOdd = gFalse; static GBool printOnlyEven = gFalse; +static GBool singleFile = gFalse; static double resolution = 0.0; static double x_resolution = 150.0; static double y_resolution = 150.0; @@ -87,6 +90,8 @@ "print only odd pages"}, {"-e", argFlag, &printOnlyEven, 0, "print only even pages"}, + {"-singlefile", argFlag, &singleFile, 0, + "write only the first page and do not add digits"}, {"-r", argFP, &resolution, 0, "resolution, in DPI (default is 150)"}, @@ -304,9 +323,20 @@ // get page range if (firstPage < 1) firstPage = 1; + if (singleFile && lastPage < 1) + lastPage = firstPage; if (lastPage < 1 || lastPage > doc->getNumPages()) lastPage = doc->getNumPages(); + if (singleFile && firstPage < lastPage) { + if (!quiet) { + fprintf(stderr, + "Warning: Single file will write only the first of the %d pages.\n", + lastPage + 1 - firstPage); + } + lastPage = firstPage; + } + // write PPM files paperColor[0] = 255; paperColor[1] = 255; @@ -348,9 +378,14 @@ pg_h = tmp; } if (ppmRoot != NULL) { - snprintf(ppmFile, PPM_FILE_SZ, "%.*s-%0*d.%s", - PPM_FILE_SZ - 32, ppmRoot, pg_num_len, pg, - png ? "png" : jpeg ? "jpg" : mono ? "pbm" : gray ? "pgm" : "ppm"); + const char *ext = png ? "png" : jpeg ? "jpg" : mono ? "pbm" : gray ? "pgm" : "ppm"; + if (singleFile) { + snprintf(ppmFile, PPM_FILE_SZ, "%.*s.%s", + PPM_FILE_SZ - 32, ppmRoot, ext); + } else { + snprintf(ppmFile, PPM_FILE_SZ, "%.*s-%0*d.%s", + PPM_FILE_SZ - 32, ppmRoot, pg_num_len, pg, ext); + } savePageSlice(doc, splashOut, pg, x, y, w, h, pg_w, pg_h, ppmFile); } else { savePageSlice(doc, splashOut, pg, x, y, w, h, pg_w, pg_h, NULL); --- poppler-0.15.2/utils/pdftoppm.1- 2010-10-17 17:16:50.000000000 +0200 +++ poppler-0.15.2/utils/pdftoppm.1 2010-12-01 18:08:58.326882351 +0100 @@ -35,6 +35,9 @@ .B \-e Generates only the even numbered pages. .TP +.BI \-singlefile +Writes only the first page and does not add digits. +.TP .BI \-r " number" Specifies the X and Y resolution, in DPI. The default is 150 DPI. .TP