Bug 50914 - pdfseparate - error checking for destFileName precludes use of valuable sprintf options
Summary: pdfseparate - error checking for destFileName precludes use of valuable sprin...
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: utils (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-09 08:01 UTC by Joe Mooring
Modified: 2013-10-02 18:36 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
allow zero-padded pagespecs (1.07 KB, patch)
2013-09-16 18:21 UTC, Daniel Kahn Gillmor
Details | Splinter Review

Description Joe Mooring 2012-06-09 08:01:32 UTC
When using pdfseparate, if the first page number and the last page number are not equal, the destination file name is checked to make sure it includes %d.

This error checking is far too restrictive -- it precludes the use of many useful sprintf format options.

For example, I would like to separate a 100 page pdf file as follows:
destination-001.pdf
destination-002.pdf
...
destination-099.pdf
destination-100.pdf

I should be able to use this standard sprintf syntax:
pdfseparate source.pdf destination-%03d.pdf

However, since destFileName does not contain %d, this command throws an error:
"Error: 'file-%03d.pdf' must contain '%d' if more than one page should be extracted

To work around this, I'm adding %%d to the end of the file name (to satisfy the error checking requirement), then renaming all the files afterwards:
pdfseparate source.pdf destination-%03d.pdf.%%d

Options:
a) Refine the error checking to handle all sprintf format options
b) Remove the error checking
Comment 1 Thomas Freitag 2012-06-09 11:24:41 UTC
Nice idea!
Feel free to implement and upload a patch fot it!
Comment 2 Daniel Kahn Gillmor 2013-09-16 18:21:56 UTC
Created attachment 85930 [details] [review]
allow zero-padded pagespecs

This is a pretty dumb patch that enables the use of %01d, %02d, ... up to %09d.  If you have a billion-page PDF it won't let you zero-pad it properly :P

It doesn't change the current default non-zero-padded behavior of %d (i don't know if anyone is relying on that) and it doesn't auto-detect what the size of the zero-padding should be.

The patch was written to apply to 0.22-5, i think.
Comment 3 Albert Astals Cid 2013-09-25 18:39:32 UTC
Looks, ok to me. Thomas, what's your opinion?
Comment 4 Thomas Freitag 2013-09-26 07:29:27 UTC
(In reply to comment #3)
> Looks, ok to me. Thomas, what's your opinion?

Looks ok for me, too!
Comment 5 Albert Astals Cid 2013-10-02 18:36:55 UTC
Commited, will be available in poppler 0.26

Thanks for your patience :-)


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.