pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Inserting PNG with transparent background to PDF using PDFBox
Date Thu, 29 Sep 2016 18:41:04 GMT
Am 29.09.2016 um 13:25 schrieb Ján Kaššovic:
> Hi,
>
> thank you for pointing me to that class, it is the first time I see such a
> thing work and I hopefully would be able to use it to achieve viable
> solution.
> I went through the example and you've said that I should have "set the
> transparency". I did not noticed such thing anywhere in the example, there
> is just straight up load, which creates a BufferedImage with the color
> model that has a Transparency type BITMASK. If I load the PNG I've attached
> in the same fashion as it is in the LosslessFactoryTest, I get Transparency
> type TRANSLUCENT. I have to therefore disable couple of asserts and
> validations, but at the end it produces the pdf output as it was with the
> gif, with 1 major difference, no transparency kept from PNG.
>
> Why did I made an "inception like" image load? I am actually generating the
> PNG programatically as an input. I've met with issues when it came to
> achieving transparency, the first thing that worked was
> creating a first image that was transparent and use its ImageData as a
> source for the final java.awt.Image. Also the stackoverflow comment claimed
> it worked after some version. That's just the reasoning why I went for it,
> not claiming it is the correct thing to do.

The transparency is set by setting the alpha byte (the highest byte) to 
something between 0 and 255. For example, you could decide that 
everything with an rgb value close to 255 255 255 should be fully 
transparent (0).

Tilman


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message