[gs-devel] Separate color pages
Russell Lang
gsview at ghostgum.com.au
Tue Aug 27 03:02:15 PDT 2002
Carsten
> i need a programm that puts the colored pages of a pdf file and the
> monochrom pages of a pdf file in two separate pdf files. I made a
> programm (attached) using the ghostscript api that analyses and prints
> out which pages are colored and which are monochrom. This works so far.
> Unfortunatly copying the input pdf or postscript file to a temporary
> file between the "showpages" does not work. The reason must be that the
> gsapi_set_stdio call does not function on regular postscript/pdf file
> input. Do you know what I have to change to make this work? I dont care
> if the input pdf/postscript file has to be conforming. I often used
> distiller to produce conforming postscript out of non conforming (DSC)
> postscript by converting to pdf and back to postscript. In fact it does
> not matter if I have to work on postscript or pdf.
gsapi_set_stdio is used for to redirect the PostScript
interpreter stdio, not the device stdio.
Output from (for example) pswrite will go to a file or the real
stdout. Output from the PostScript "print" operator will go to
the stdout callback or to the real stdout.
I would use three passes to do the conversion.
First pass identifies the monochrome and colour pages.
Second pass processes the monochrome pages.
Third pass processes the colour pages.
Have a look at pdf2dsc.ps, which writes a PostScript DSC
conformant file that references the PDF file. You could either
use this and something like psselect (from PSutils), or from you
program write the appropriate PostScript code to ghostscript.
Better still would be to extract the pages from the PDF file
without reinterpreting it. I don't think ghostscript can do
this, but it is practical. There should be tools available
which can extract pages from a PDF file. It is a matter of
writing all the PDF objects references by the selected pages,
and updating the object numbers.
Russell Lang gsview at ghostgum.com.au
Ghostgum Software Pty Ltd http://www.ghostgum.com.au/
More information about the gs-devel
mailing list