[reportlab-users] [PATCH] PDF Transparency

King Simon-NFHD78 simon.king at motorola.com
Fri Nov 28 09:13:59 EST 2008



> -----Original Message-----

> From: reportlab-users-bounces at reportlab.com

> [mailto:reportlab-users-bounces at reportlab.com] On Behalf Of

> King Simon-NFHD78

> Sent: 27 November 2008 18:10

> To: Support list for users of Reportlab software

> Subject: Re: [reportlab-users] PDF Transparency

>

> OK, here's the patch - it's a little ugly at the moment.

>

> I was thinking a little more about managing the ExtGState

> dictionaries.

> Do you think it is reasonable to create a state for each 'extended

> attribute' value? For example, setting both the stroke alpha and fill

> alpha results in the creation of two states. This keeps the canvas

> interface nice and simple, possibly at the expense of efficiency.

>

> I suppose you could expose add_extgstate method and activate_extgstate

> as well, for users who want to manage them manually.

>

> Thanks again,

>

> Simon

>


Here's an updated version of the patch, and an example PDF with the
results.

With this new patch, reportlab should generate exactly the same PDFs
that it has always done (including the version, 1.3) if you don't ever
call canvas.setStrokeAlphaConstant or canvas.setFillAlphaConstant. If
you call one of those functions, a version 1.4 PDF will be generated
instead.

It now caches the graphics states, so there will only be a single state
for each transparency level used.

I think it would be fairly easy to add different blend modes, but I
haven't done it. I also haven't done anything about transparency mask
shapes - I've no idea if they would be easy to implement.

I hope this can be considered for inclusion in ReportLab, but I am happy
to continue to use my patched version if it is not acceptable. I think
it does everything I need at this point so I probably won't be putting
any more work into it for the moment.

Thanks,

Simon King
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transparency.pdf
Type: application/octet-stream
Size: 3025 bytes
Desc: transparency.pdf
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20081128/c9308681/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reportlab_opacity_patch2.patch
Type: application/octet-stream
Size: 11984 bytes
Desc: reportlab_opacity_patch2.patch
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20081128/c9308681/attachment-0003.obj>


More information about the reportlab-users mailing list