[reportlab-users] Transparent PNG support
Robin Becker
robin at reportlab.com
Tue Dec 11 05:14:51 EST 2007
Darryl Woods wrote:
> Hi all,
>
> I am creating a report with ReportLab, and as part of this I have
> extended the Table class to do some custom drawing for table borders and
> such. Part of the design, however, is that the right side of the tables
> "fade out" to white, using a gradient. (The report was designed by a
> graphic designer...)
>
> I've tried various things:
>
> - placing a dithered black/white GIF image and setting the transparency
> mask (looks very bad)
> - placing a PNG with transparency (transparency doesn't appear)
> - drawing a series of vertical lines, getting increasingly lighter (no
> transparency though)
>
> Is there any way I can accomplish this?
>
> Thanks,
> Darryl
interestingly the same kind of problem came up in a different context and I have
just finished getting png transparency into a working state.
The code is a bit hacky at present because not everything can be done cleanly in
one place. You'll need the latest svn version for this though.
Anyhow, for images created with canvas.drawImage, rgba transparency seems to be
working. There are two examples in test_pdfgen_general.py showing that rgba
images can do the 'right' thing. Presumably with a table background you need to
override the draw method to place the image behind the table and then do the
table draw or something like that anyhow. You won't be able to get more than 255
levels of transparency (I think), but perhaps that's enough.
Of course there are other more effective ways to do this within PDF, but the
other context hasn't asked for those yet ;)
--
Robin Becker
More information about the reportlab-users
mailing list