[cups.development] A postscript rendering filter

Matt Anderson mra at hp.com
Fri May 19 15:03:36 PDT 2006


The problem I'm trying to solve is how to take a multipage postscript
document and render it to bitmaps so that it can be passed along to
other filters and eventually to a printer for the purpose of an LSPP
Common Criteria evaluation.  Since LSPP requires the system to have the
ability to label all output, a filter is needed to be able to apply
banners to the top and bottom of each printed page.  Given the
postscript is a complete language its possible for malicious postscript
to override these banners, which cannot happen.

One intermediate idea was to convert the PS to PDF, this solves the
multiple pages issue nicely, but the PDF spec is very large so that
presents a documentation problem when it comes to a low level design for
meeting EAL4.  So far the solution I have is to render the postscript
and pass along images which will have a higher level of trust.  This has
a drawback of still requiring postscript as the output container as I am
not aware of any image format which support multiple pages.

Currently I'm doing this by using the utility psselect to extract a
single page from a multipage document.  This single postscript page is
then converted to a TIFF using the a2ping utility, this TIFF is then
converted to an EPS encoded image file.  Once all the pages have been
rendered the filter glues them all together with some postscript.

The output starts with a mostly static postscript header.  The dynamic
parts of this are the document's title, number of pages, and page size
(paper size).  After that header a per-page header is sent, the only
dynamic portions of which are the page size and the EPS comment
%%BeginDocument $(filename)-$(page number)  Then the rendered image is
sent, followed by a short static per page footer.  Once all of the pages
have been sent a short static postscript footer is sent and the filter
performs any needed cleanup.

This currently works with a limited set of input.  Specifically letter
sized documents which fill the page naturally, not using moveto to
position small amounts of text at arbitrary positions on the page.

Overcoming the letter size page hurdle seems feasible.  It will require
reading the BoundingBox size from the input postscript and utilizing
that in various matrix calculations.  The results of which will be
encoded into the output postscript.

So far the only idea I have for solving the moveto issue is to center
the rendered image on the output page.  This will work, but if for
example the PS document has a 1 inch square in the lower left corner of
the page this would be moved to the center, which is not desirable.

Feedback or suggestions are welcome.  Pointers to multipage image
formats, or pre-existing filters which handle this issue would be ideal.

-matt





More information about the cups-devel mailing list