Bug#723121: /usr/bin/pdfseparate: pdfseparate should handle left-padding PDF page pattern (e.g. %03d)
Package: poppler-utils Version: 0.22.5-2 File: /usr/bin/pdfseparate It would be really nice if pdfseparate could apply left-hand padding to the page files it creates, along the lines of: 0 dkg@alice:~$ pdfseparate ../test.pdf page-%03d.pdf Syntax Error: 'page-%03d.pdf' must contain '%%d' if more than one page should be extracted 99 dkg@alice:~$ This is useful in order to create lexicographically sorted output files when a PDF has 10 or more pages. --dkg -- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (500, 'testing'), (200, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 3.11-rc4-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages poppler-utils depends on: ii libc6 2.17-92+b1 ii libcairo2 1.12.14-4 ii libfreetype6 2.4.9-1.1 ii liblcms2-22.2+git20110628-2.2 ii libpoppler37 0.22.5-2 ii libstdc++64.8.1-2 ii zlib1g1:1.2.8.dfsg-1 poppler-utils recommends no packages. poppler-utils suggests no packages. -- debconf-show failed -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#723121: /usr/bin/pdfseparate: pdfseparate should handle left-padding PDF page pattern (e.g. %03d)
severity 723121 wishlist forwarded 723121 https://bugs.freedesktop.org/show_bug.cgi?id=50914 thanks Hi, In data lunedì 16 settembre 2013 13:17:28, hai scritto: Package: poppler-utils Version: 0.22.5-2 File: /usr/bin/pdfseparate It would be really nice if pdfseparate could apply left-hand padding to the page files it creates, along the lines of: 0 dkg@alice:~$ pdfseparate ../test.pdf page-%03d.pdf Syntax Error: 'page-%03d.pdf' must contain '%%d' if more than one page should be extracted 99 dkg@alice:~$ This is useful in order to create lexicographically sorted output files when a PDF has 10 or more pages. It seems this has been asked already as fdo#50914 (with even the same padding as your example ;) ); feel free to subscribe to it, if you have an account on the fdo bugzilla. -- Pino Toscano signature.asc Description: This is a digitally signed message part.
Bug#723121: /usr/bin/pdfseparate: pdfseparate should handle left-padding PDF page pattern (e.g. %03d)
Control: tag 723121 + patch On 09/16/2013 01:28 PM, Pino Toscano wrote: forwarded 723121 https://bugs.freedesktop.org/show_bug.cgi?id=50914 thanks for the pointer, pino. attached is a patch that permits zero-padded pagespecs up to %09d. I've also submitted it to the upstream tracker. Regards, --dkg --- a/utils/pdfseparate.cc 2013-09-16 13:26:25.403397896 -0400 +++ b/utils/pdfseparate.cc 2013-09-16 13:47:01.352602022 -0400 @@ -61,9 +61,24 @@ 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++) { sprintf (pathName, destFileName, pageNo); signature.asc Description: OpenPGP digital signature