Draw transparent png image to pdf using pdfbox and seeing gray halo around the edges

41 views Asked by At

I am trying to draw the transparent png onto the Pdf using PdfBoxGraphics2D.

I am using PdfBox version - 2.0.28

pdfBoxGraphics2D.drawImage(image, transform, null);

and I am overriding the encodeImage() method of PdfBoxGraphics2DLosslessImageEncoder as below

pdImageXObject = LosslessFactory.createFromImage(document, bufferedImage);
                    if (imageKey != null) {
                        ((PdfResourceCache) document.getResourceCache()).addImageToCache(imageKey, pdImageXObject);
                    }

and we are seeing transparent PNG images appear in PDFs with gray halo around the edges like below. Any help on the fix is greatly appreciated.

enter image description here

and here are the transparent png images I am trying draw onto the pdf.

enter image description here

and

enter image description here

0

There are 0 answers