[poppler] utils/pdftoppm.1 utils/pdftoppm.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 19 23:04:06 UTC 2019


Rebased ref, commits from common ancestor:
commit a1e0f77578e88b9f089fd88ccba0608a24f2901c
Author: Yves-Gaël Chény <gitlab at r0b0t.fr>
Date:   Mon Mar 11 12:20:40 2019 +0100

    add to parameters for command line tools pdftoppm
    
    -sep : single character separor between name and page number, default -
    -forcenum : force page number even if there is only one page

diff --git a/utils/pdftoppm.1 b/utils/pdftoppm.1
index 75a4f473..79d78f4b 100644
--- a/utils/pdftoppm.1
+++ b/utils/pdftoppm.1
@@ -135,6 +135,12 @@ Specify the user password for the PDF file.
 .B \-q
 Don't print any messages or errors.
 .TP
+.BI \-sep " char"
+Specify single character separator between name and page number, default - .
+.TP
+.B \-forcenum
+Force page number even if there is only one page.
+.TP
 .B \-v
 Print copyright and version information.
 .TP
diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc
index 7d72c8d2..03d416e5 100644
--- a/utils/pdftoppm.cc
+++ b/utils/pdftoppm.cc
@@ -28,6 +28,7 @@
 // Copyright (C) 2013 Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
 // Copyright (C) 2015 William Bader <williambader at hotmail.com>
 // Copyright (C) 2018 Martin Packman <gzlist at googlemail.com>
+// Copyright (C) 2019 Yves-Gaël Chény <gitlab at r0b0t.fr>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -86,6 +87,8 @@ static int sz = 0;
 static bool useCropBox = false;
 static bool mono = false;
 static bool gray = false;
+static char sep[2] = "-";
+static bool forceNum = false;
 static bool png = false;
 static bool jpeg = false;
 static bool jpegcmyk = false;
@@ -156,6 +159,10 @@ static const ArgDesc argDesc[] = {
    "generate a monochrome PBM file"},
   {"-gray",   argFlag,     &gray,          0,
    "generate a grayscale PGM file"},
+  {"-sep",   argString,      sep, sizeof(sep),
+    "single character separator between name and page number, default - "},
+  {"-forcenum",   argFlag,      &forceNum, 0,
+	"force page number even if there is only one page "},
 #ifdef ENABLE_LIBPNG
   {"-png",    argFlag,     &png,           0,
    "generate a PNG file"},
@@ -585,12 +592,12 @@ int main(int argc, char *argv[]) {
     }
     if (ppmRoot != nullptr) {
       const char *ext = png ? "png" : (jpeg || jpegcmyk) ? "jpg" : tiff ? "tif" : mono ? "pbm" : gray ? "pgm" : "ppm";
-      if (singleFile) {
+      if (singleFile && !forceNum ) {
         ppmFile = new char[strlen(ppmRoot) + 1 + strlen(ext) + 1];
         sprintf(ppmFile, "%s.%s", ppmRoot, ext);
       } else {
         ppmFile = new char[strlen(ppmRoot) + 1 + pg_num_len + 1 + strlen(ext) + 1];
-        sprintf(ppmFile, "%s-%0*d.%s", ppmRoot, pg_num_len, pg, ext);
+        sprintf(ppmFile, "%s%s%0*d.%s", ppmRoot, sep, pg_num_len, pg, ext);
       }
     } else {
       ppmFile = nullptr;


More information about the poppler mailing list