2004 IR Help Posted August 20, 2006 Share Posted August 20, 2006 By: newbieAndreas - andreas_siebold java.awt.image's to InputStream for Jasper 2005-03-11 02:27 Hello! I am something called a Java-Newbie, and want to use Jasper to display Charts, i created with JCharts. JCharts gives me java.awt.image.bufferedimages, and I want to use them in a Field on a Jasperreport. Fields in Jasper do not accept java.awt.images. Only chance is, to give him inputstreams. My BIG problem is: How can I create a inputstream from my bufferedImage, without saving it on the Filesystem. It would be great if somebody could help me with this, I am trying to create thees report's since 2 weeks now, and slowly I'm close to a nervous breakdown... I am using a JRBeanCollectionDataSource() and JasperFillManager.fillReport(...) from my javaservlet for the creation, and the JRPdfExporter for the export... Thanks Andreas By: newbieAndreas - andreas_siebold RE: java.awt.image's to InputStream for Jaspe 2005-03-11 05:52 Or else, is there another chance to put my bufferedimages into the Jasperreports using a Datsource collection??? By: Denny Valliant - xenden RE: java.awt.image's to InputStream for Jaspe 2005-03-11 10:39 Well, it may be a case of newbie helping newbie, so bear with me, but this code in ColdFusion (close to java,sorta) say's it converts buffered to stream... daXM is a string. A JRXML, actually... but maybe this will lead you in the right direction... xmlBuffer = CreateObject("java","java.lang.String").init(daXM).getBytes(); //Turn the buffers into input streams xmlInputStream = CreateObject("java","java.io.ByteArrayInputStream").init(xmlBuffer); outStream = CreateObject("java","java.io.ByteArrayOutputStream").init(); By: charmadi - charmadi RE: java.awt.image's to InputStream for Jasper 2005-03-15 14:53 This is what you can do. Create a variable of type java.awt.Image. Then create a scriplet class extending from JRDefaultScriptlet class and override one of the function. If you want to create the chart only once then override public void afterReportInit() function and in that function create your image using JChart then use the function setVariableValue("variableName", image); Don't forget to set your scriplet class name in scriptletClass="your scriplet ClassName" attribute of jasperReport element. Hope this helps. By: Friedemann Becker - fnbecker RE: java.awt.image's to InputStream for Jaspe 2005-03-16 01:05 if you wan't to display externally created images, you can just pass them as java.lang.object to a parameter. create an image tag and set the type to java.awt.image, your object is automatically casted then. you even could generate charts server side, put them in a byte-array, transfer it to the client via say axis/jaxrpc, load it there and pass it to your report. if you do things like that, don't forget to implement an image-listener that waits for the image being loaded, this is needed even if images are created from memory by a byte array. hope this helps, greetings By: newbieAndreas - andreas_siebold RE: java.awt.image's to InputStream for Jaspe 2005-03-16 02:12 THX very very much to everyone who replied. Especially to fnbecker!!! Put the image into my Datasource as Objects did work... I never thought that the answer would be so simple... Now I got my believe in Jasper back .. :) Greeting's ... andreas 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