neian Posted April 10, 2007 Share Posted April 10, 2007 Hello, I have a problem in the image embedded in the pdf file that jasper report generated. The image was not transparent and has a dark grey color. This occurred when I used PJA toolkit to be able to run the JasperFillManager.fillReport(xx) in our unix server. I am using the code below to get the image. Image logo = new ImageIcon(imageURL).getImage(); In the jrxml, the image is declared as an Image object. <image scaleImage="RetainShape" isLazy="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement mode="Transparent" x="191" y="30" width="167" height="62" key="image-1"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <graphicElement stretchType="NoStretch" pen="None"/> <imageExpression class="java.awt.Image"><![CDATA[$P{Logo}]]></imageExpression></image> Maybe somebody has also encountered this and can share their insights on what could be the cause of the image problem and how to solve it? Thanks. Link to comment Share on other sites More sharing options...
Teodor Danciu Posted April 20, 2007 Share Posted April 20, 2007 Hi, Are you sure you need PJA? I mean, have you tried the -Djava.awt.headless=true? I hope this helps.Teodor Link to comment Share on other sites More sharing options...
neian Posted April 24, 2007 Author Share Posted April 24, 2007 Hello, Thank you for the suggestion but I cannot set the java.awt.headless = true since I am using jdk 1.3. However I was able to find a solution for my problem. I just need to put my Image in a BufferedImage and use the Graphics2D to draw the Image. In order to use jasper reports in the Unix environment, we used PJA toolkit and just set the server properties as per PJA documentation. Below is the code I used to generate the Image. public static Image getLogo() { URL imageURL = Thread.currentThread().getContextClassLoader().getResource("images/WMS_K_2.jpg"); ImageIcon icon = new ImageIcon(imageURL); BufferedImage logo = new BufferedImage(icon.getIconWidth(),icon.getIconHeight(),BufferedImage.TYPE_INT_RGB); Graphics2D graphics = logo.createGraphics(); graphics.drawImage(icon.getImage(),0,0,icon.getImageObserver()); return logo; } Link to comment Share on other sites More sharing options...
Teodor Danciu Posted April 24, 2007 Share Posted April 24, 2007 Hi, Is this a solution recommended by PJA or is something you found by trial and error? Thanks,Teodor Link to comment Share on other sites More sharing options...
neian Posted April 25, 2007 Author Share Posted April 25, 2007 Hello, To be able to display the image in a pdf, I found the solution in the PJA Toolkit forum. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now