[poppler] utils/pdfseparate.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Wed Oct 2 11:50:16 PDT 2013
utils/pdfseparate.cc | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
New commits:
commit fa83d7e4f36cfc11c7b4f81f5f5e8ed69eb6dbbe
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date: Wed Oct 2 20:35:58 2013 +0200
pdfseparate: allow zero-padded pagespecs
Bug #50914
diff --git a/utils/pdfseparate.cc b/utils/pdfseparate.cc
index 1d4901b..2844dc5 100644
--- a/utils/pdfseparate.cc
+++ b/utils/pdfseparate.cc
@@ -7,6 +7,7 @@
// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
// Copyright (C) 2012 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2013 Pino Toscano <pino at kde.org>
+// Copyright (C) 2013 Daniel Kahn Gillmor <dkg at fifthhorseman.net>
//
//========================================================================
#include "config.h"
@@ -62,9 +63,24 @@ bool extractPages (const char *srcFileName, const char *destFileName) {
lastPage = doc->getNumPages();
if (firstPage == 0)
firstPage = 1;
- if (firstPage != lastPage && strstr(destFileName, "%d") == NULL) {
- error(errSyntaxError, -1, "'{0:s}' must contain '%%d' if more than one page should be extracted", destFileName);
- return false;
+ if (firstPage != lastPage) {
+ bool foundmatch = false;
+ if (strstr(destFileName, "%d") != NULL) {
+ foundmatch = true;
+ } else {
+ char pattern[5];
+ for (int i = 2; i < 10; i++) {
+ sprintf(pattern, "%%0%dd", i);
+ if (strstr(destFileName, pattern) != NULL) {
+ foundmatch = true;
+ break;
+ }
+ }
+ }
+ if (!foundmatch) {
+ error(errSyntaxError, -1, "'{0:s}' must contain '%%d' if more than one page should be extracted", destFileName);
+ return false;
+ }
}
for (int pageNo = firstPage; pageNo <= lastPage; pageNo++) {
snprintf (pathName, sizeof (pathName) - 1, destFileName, pageNo);
More information about the poppler
mailing list