[poppler] 2 commits - poppler/Function.cc utils/pdftoppm.1 utils/pdftoppm.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Apr 4 04:34:20 PDT 2010


 poppler/Function.cc |   12 +++++++-----
 utils/pdftoppm.1    |    6 ++++++
 utils/pdftoppm.cc   |    8 ++++++++
 3 files changed, 21 insertions(+), 5 deletions(-)

New commits:
commit ab5044e451e3714d385295f0b4ce9a15c8f2562c
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Apr 4 12:32:42 2010 +0100

    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

diff --git a/utils/pdftoppm.1 b/utils/pdftoppm.1
index fee97f8..de2405c 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 5b318be..7d1e3bf 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);
commit 0e371fb628a7e7d0cc1656e6405af4c97dbebf5d
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Apr 4 12:30:34 2010 +0100

    Fix my roll optimization
    
    Thanks Carlos for noticing

diff --git a/poppler/Function.cc b/poppler/Function.cc
index 73a6b5f..b7c23fe 100644
--- a/poppler/Function.cc
+++ b/poppler/Function.cc
@@ -13,7 +13,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2006, 2008, 2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2008-2010 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006 Jeff Muizelaar <jeff at infidigm.net>
 //
 // To see a description of the changes please see the Changelog file that
@@ -1012,11 +1012,13 @@ void PSStack::roll(int n, int j) {
     }
   } else {
     j = n - j;
-    obj = stack[sp + n - 1];
-    for (k = sp + n - 1; k > sp; --k) {
-      stack[k] = stack[k-1];
+    for (i = 0; i < j; ++i) {
+      obj = stack[sp + n - 1];
+      for (k = sp + n - 1; k > sp; --k) {
+        stack[k] = stack[k-1];
+      }
+      stack[sp] = obj;
     }
-    stack[sp] = obj;
   }
 }
 


More information about the poppler mailing list