[reportlab-users] PDF Transparency
simon.king at motorola.com
Thu Nov 27 12:24:58 EST 2008
Does anyone have any plans to support the PDF Transparency model in
I had a need for basic support (just the stroking and non-stroking alpha
constants), which I've managed to hack in to reportlab. However, I don't
know if the method is suitable for general consumption. In particular, I
don't know if it would make it difficult to support the more general
The basic idea was:
* add an attribute to the canvas that tracks ExtGStates
* add set[Non]StrokeAlphaConstant methods that create and activate new
* in canvas.showPage, pass the ExtGStates on to the page
* add strokeOpacity and fillOpacity to some of the shapes in
* update _PDFRenderer.applyStateChanges to pas those properties on to
I also had to update PDFHeader to PDF version 1.4, because that is the
first version that supported transparency.
This is the first time I've looked at both the PDF spec and the
reportlab code, so I've probably done something very silly. Does this
approach sound reasonable?
One flaw at the moment is that a new graphics state gets created every
time you call set[Non]StrokeAlphaConstant, even if you pass the same
parameter. It would be much better to reuse states if possible.
I can post the patch if anyone is interested.
Thanks for listening,
More information about the reportlab-users