[reportlab-users] Wrong order of Filters in page streams
Bernhard Herzog
reportlab-users@reportlab.com
05 Jul 2002 14:57:24 +0200
I'm finally getting around to turn my EuroPython presentation into PDF.
As the generated file is more than 1.6MB large I had a closer look at it
to find out whether it was compressed. Turns out that it is compressed
(the large size is mainly due to some of the embedded graphics having
complex gradients) but the order of the filters is a bit strange:
% page stream
<< /Filter [ /FlateDecode
/ASCII85Decode ]
/Length 16339 >>
stream
followed by lots of binary bytes.
The above filter specification means that the stream will be first flate
decoded and then ASCII85 decoded (i.e. it was created by first ASCII85
encoding it and then compressing it).
If the stream is ASCII85 encoded at some point it should happen after
the compression so that the PDF contains only ASCII data.
I think the bug is in the PDFPage.check_format method (pdfdoc.py:985)
where the filters are defined [PDFZCompress, PDFBase85Encode]. The
PDFStream.format method reverses the list of filters before applying the
filters, though.
I've played around with it a bit, and removed the ASCII85 filter in
PDFPage.check_format. The resulting file is about a third as large as
before!
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
MapIt! http://www.mapit.de/