summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2010-04-04 12:32:42 +0100
committerAlbert Astals Cid <aacid@kde.org>2010-04-04 12:33:33 +0100
commitab5044e451e3714d385295f0b4ce9a15c8f2562c (patch)
tree0feeee0418993051a7d34f99fd932cbf3023a1c9 /utils
parent0e371fb628a7e7d0cc1656e6405af4c97dbebf5d (diff)
Add the -o[dd] and -e[ven] options to pdftoppm
I've been using this patch forever and it's a pain to apply and unapply it each time
Diffstat (limited to 'utils')
-rw-r--r--utils/pdftoppm.16
-rw-r--r--utils/pdftoppm.cc8
2 files changed, 14 insertions, 0 deletions
diff --git a/utils/pdftoppm.1 b/utils/pdftoppm.1
index fee97f81..de2405c2 100644
--- a/utils/pdftoppm.1
+++ b/utils/pdftoppm.1
@@ -29,6 +29,12 @@ Specifies the first page to convert.
.BI \-l " number"
Specifies the last page to convert.
.TP
+.B \-o
+Generates only the odd numbered pages.
+.TP
+.B \-e
+Generates only the even numbered pages.
+.TP
.BI \-r " number"
Specifies the X and Y resolution, in DPI. The default is 150 DPI.
.TP
diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc
index 5b318be6..7d1e3bf0 100644
--- a/utils/pdftoppm.cc
+++ b/utils/pdftoppm.cc
@@ -44,6 +44,8 @@
static int firstPage = 1;
static int lastPage = 0;
+static GBool printOnlyOdd = gFalse;
+static GBool printOnlyEven = gFalse;
static double resolution = 0.0;
static double x_resolution = 150.0;
static double y_resolution = 150.0;
@@ -74,6 +76,10 @@ static const ArgDesc argDesc[] = {
"first page to print"},
{"-l", argInt, &lastPage, 0,
"last page to print"},
+ {"-o", argFlag, &printOnlyOdd, 0,
+ "print only odd pages"},
+ {"-e", argFlag, &printOnlyEven, 0,
+ "print only even pages"},
{"-r", argFP, &resolution, 0,
"resolution, in DPI (default is 150)"},
@@ -287,6 +293,8 @@ int main(int argc, char *argv[]) {
if (sz != 0) w = h = sz;
pg_num_len = (int)ceil(log((double)doc->getNumPages()) / log((double)10));
for (pg = firstPage; pg <= lastPage; ++pg) {
+ if (printOnlyEven && pg % 2 == 0) continue;
+ if (printOnlyOdd && pg % 2 == 1) continue;
if (useCropBox) {
pg_w = doc->getPageCropWidth(pg);
pg_h = doc->getPageCropHeight(pg);