Flaxxed wrote: > > I have a report that has multiple images in it. [snip] All of the images > that are put in the report have a transparent background. [snip] However, > when I use the JasperExportManager.exportReportToPdf() method, the images' > transparencies do not work [snip] >
I ran into the same problem, but wasn't able to find a solution on the web. I contacted Flaxxed, who posed the question above, and luckily he had found a solution. The gist of the solution is to pass a JRRenderable object to Jasper and not a java.awt.Image. I found that in addition I needed to ensure that my Image files were sent to Jasper as a png with an alpha channel. Below is the code that I ended up with. imageOriginal = ... whatever your image source is... // These steps are necessary to ensure that transparency works int height = imageOriginal.getHeight( null ); int width = imageOriginal.getWidth( null ); bufferedImage = new BufferedImage( width, height, BufferedImage.TYPE_4BYTE_ABGR ); Graphics2D graphics = bufferedImage.createGraphics(); graphics.drawImage( imageOriginal, 0, 0, null ); graphics.dispose(); JRRenderable jrRenderable = JRImageRenderer.getInstance( image, JRRenderable.IMAGE_TYPE_PNG, JRImage.ON_ERROR_TYPE_ERROR ); return jrRenderable; JRImageRenderer.getInstance did not work properly until I forced it to PNG. I hope this helps. -- View this message in context: http://www.nabble.com/Transparent-Images-in-exportToPDF%28%29-tp14815882p17243580.html Sent from the jasperreports-questions mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ jasperreports-questions mailing list jasperreports-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jasperreports-questions