[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cups
Subject:    Re: [cups.general] Alternative way to find no. of pages inside PDF?
From:       James Cloos <cloos () jhcloos ! com>
Date:       2008-06-17 7:28:53
Message-ID: 32947-cups.general () news ! easysw ! com
[Download RAW message or body]

pdfinfo gets the number of pages by counting them as it traverses the
object hierarchy.

Looking at some of the postscript file in gs's lib dir, it looks like
the ps function pdfpagecount will do what you want.

Specifically, something like this untested code:

    %!
    % run using:
    % gs -dNODISPLAY -sPDFname=pdffilename pdfpagecount.ps
    systemdict /.setsafe known { .setsafe } if
    GS_PDF_ProcSet begin
    pdfdict begin
    /PDFname (r) file
    pdfopen begin
    (%stdout) (w) file dup dup
    pdfpagecount 10 string cvs
    writestring
    (\n) writestring
    flushfile
    quit

(Note that gs prints its copyright info to stdout, you may want
to pipe it to tail -1 or grep for ^[0-9] or some such.)

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6


_______________________________________________
cups mailing list
cups@easysw.com
http://lists.easysw.com/mailman/listinfo/cups
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic