[gs-bugs] [Bug 692250] Add -sPages option

bugzilla-daemon at ghostscript.com bugzilla-daemon at ghostscript.com
Thu Jun 23 13:51:21 UTC 2011


--- Comment #9 from cryptopsy at live.com 2011-06-23 13:51:21 UTC ---
Assume a 10 page document called original.pdf, then splitting pdf ranges is
very easy.

The split command unit is;

' gs -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -q -dFirstPage=$page -dLastPage=$page
-o original.pdf-$page original.pdf' 

and the ranges are managed with shell (for loops for specific ranges). For
automated splitting, there is still a problem - the error code is reported
incorrectly. Assume the document is 10 pages in lenght, attempt to extract the
12th page with this automated statement ;

' while [[ "$?" == "0" ]]; do   ... ';

...would produce;
'Requested FirstPage is greater than the number of pages in the file: 12
   No pages will be processed (FirstPage > LastPage).'

This is wrong because
1)  FirstPage > LastPage is wrong, as proven by specifying FirstPage=LastPage
in the range of the document.
2) The error code for a succesful split is also 0. 

Proof, via the 10 page document;
# gs -sDEVICE=pdfwrite -dFirstPage=12 -dLastPage=12 -o test.pdf-12 test.pdf ;
echo $? 
# gs -sDEVICE=pdfwrite -dFirstPage=9 -dLastPage=9 -o test.pdf-12 test.pdf ;
echo $? 

The documentation has something to say, could someone clarify this?
# elinks /usr/share/doc/ghostscript-gpl-8.71-r6/html/Use.htm
   Note however that the one page per file feature is not supported by all     
   devices; in particular it does not work with document-oriented output       
   devices like pdfwrite and pswrite. See the -dFirstPage and -dLastPage       
   switches below for a way to extract single pdf pages. 

Configure bugmail: http://bugs.ghostscript.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the gs-bugs mailing list