[gs-devel] Splitting a multipage pdf

Ralph Giles giles at ghostscript.com
Thu Apr 2 13:05:45 PDT 2009

On Thu, Apr 2, 2009 at 11:36 AM, Jeremy Rottman <rottmanj at hsmove.com> wrote:
> I know that I can split a multi-page pdf if I use something like below. But
> the issue that I am having is that I will never know exactly how many pages
> are in the pdf files that I am working with. Is there a way to determine the
> number of pages or even better is there a way to split the pdf with out
> passing the firstpage or lastpage?

The pdf_info.ps script will extract some metadata for you. If you can
parse that, you can use it to set your page ranges. e.g.

gs -dNODISPLAY -q -sFile=FAX200904010240-1.PDF toolbin/pdf_info.ps

The toolbin/pdf_info.ps script is available from the gs source
distribution. For example

The output looks like this:

$ bin/gs -dNODISPLAY -q -sFile=../spec/PLRM.pdf toolbin/pdf_info.ps

../spec/PLRM.pdf has 912 pages.
Title: PostScript Language Reference, third edition
Author: Adobe Systems Incorporated
Creator: FrameMaker 5.5.3
Producer: Acrobat Distiller 3.01 for Power Macintosh
CreationDate: D:19990209122259
ModDate: D:19990226085122


More information about the gs-devel mailing list