[poppler] Branch 'poppler-0.14' - utils/pdftoppm.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Jul 15 02:53:09 PDT 2010


 utils/pdftoppm.cc |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 22744e9150bd6ce5c9e3c57bc92b867d2bb4380c
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Jul 15 10:51:21 2010 +0100

    Fix padding of names
    
    The previous method returned 2 for documents with 100 pages, which is wrong as 100 needs 3
    characters, not 2

diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc
index 849e79f..ed64fea 100644
--- a/utils/pdftoppm.cc
+++ b/utils/pdftoppm.cc
@@ -188,6 +188,18 @@ static void savePageSlice(PDFDoc *doc,
   }
 }
 
+static int numberOfCharacters(unsigned int n)
+{
+  int charNum = 0;
+  while (n >= 10)
+  {
+    n = n / 10;
+    charNum++;
+  }
+  charNum++;
+  return charNum;
+}
+
 int main(int argc, char *argv[]) {
   PDFDoc *doc;
   GooString *fileName = NULL;
@@ -296,7 +308,7 @@ int main(int argc, char *argv[]) {
 				  gFalse, paperColor);
   splashOut->startDoc(doc->getXRef());
   if (sz != 0) w = h = sz;
-  pg_num_len = (int)ceil(log((double)doc->getNumPages()) / log((double)10));
+  pg_num_len = numberOfCharacters(doc->getNumPages());
   for (pg = firstPage; pg <= lastPage; ++pg) {
     if (printOnlyEven && pg % 2 == 0) continue;
     if (printOnlyOdd && pg % 2 == 1) continue;


More information about the poppler mailing list