divsen Posted October 18, 2006 Share Posted October 18, 2006 Hi I have many images stored in my database as BLOB.when i get the data they are as bytes. so i have field image which of type byte. how do i print the image on the report. how do i convert it into inputstream or any other format. Is there any way to do it in ireport or can it be done only in code like this: InputStream in = new ByteArrayInputStream(byte[]); Thanks Link to comment Share on other sites More sharing options...
lucianc Posted October 18, 2006 Share Posted October 18, 2006 You can do something likeCode:<imageExpression class="java.awt.Image"> JRImageLoader.loadImage(..your image data..)</imageExpression> HTH,Lucian Link to comment Share on other sites More sharing options...
divsen Posted October 19, 2006 Author Share Posted October 19, 2006 I tried that it says 12:36:31,562 INFO [sTDOUT] Caused by: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:1. JRImageLoader cannot be resolved value = (java.awt.Image)(JRImageLoader.loadImage(((java.lang.Byte)field_companyLargeLogo.getValue()))); <-----------> Can u plz help me Link to comment Share on other sites More sharing options...
lucianc Posted October 19, 2006 Share Posted October 19, 2006 You can eitheradd Code:<import value="net.sf.jasperreports.engine.util.JRImageLoader"/> to your report, orCode:[code]<imageExpression class="java.awt.Image"> net.sf.jasperreports.engine.util.JRImageLoader.loadImage(..your image data..)</imageExpression>[/ul] HTH,Lucian Link to comment Share on other sites More sharing options...
divsen Posted October 19, 2006 Author Share Posted October 19, 2006 Thanks for your help. now my problem is 08:36:03,015 INFO [sTDOUT] Caused by: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:1. The method loadImage(byte[]) in the type JRImageLoader is not applicable for the arguments (Byte) value = (java.awt.Image)(net.sf.jasperreports.engine.util.JRImageLoader.loadImage(((java.lang.Byte)field_company__companyLargeLogo.getValue()))); <-------> Bcoz the data type i gave for the field is java.lang.Byte so i tried byteValue() but that also did not help 08:40:22,827 INFO [sTDOUT] Caused by: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:1. The method loadImage(byte[]) in the type JRImageLoader is not applicable for the arguments (byte) value = (java.awt.Image)(net.sf.jasperreports.engine.util.JRImageLoader.loadImage(((java.lang.Byte)field_company__companyLargeLogo.getValue()).byteValue())); <-------> What field type should i give to keep the value as byte[] array. Link to comment Share on other sites More sharing options...
lucianc Posted October 20, 2006 Share Posted October 20, 2006 If your field will have a byte[] as value, you need to declare the field as java.lang.Object and then cast it in your image expressionCode:net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[]) $F{logo}) If you have an SQL query in the report to retrieve the data (and you have a fairly recent JR version), you can also try to declare your field as java.awt.Image and directly use it in the image expression. Link to comment Share on other sites More sharing options...
divsen Posted October 21, 2006 Author Share Posted October 21, 2006 Thank you very much. It worked.. Link to comment Share on other sites More sharing options...
sheshkrish Posted September 2, 2008 Share Posted September 2, 2008 Hi,I am newbie to using iReports tool.i have to display a BLOB field from my ORACLE Database on a report.I have declared the field as java.lang.Object Typeand i have an image field : with this expression:net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$F{LOT_LETTERCONDITION_DTL_CONDIT})where LOT_LETTERCONDITION_DTL_CONDIT is my BLOB fieldand the expression tyep is: java.awt.ImageThe report compiles fine - but throws a run-time error giving a CLASSCASTEXCEPTIONthe exact error being --> Caused by: java.lang.ClassCastException: oracle.sql.BLOB cannot be cast to [b Kindly help me in solving this issue.Thanks in advance!Shesh. Link to comment Share on other sites More sharing options...
sheshkrish Posted September 2, 2008 Share Posted September 2, 2008 The entire log trace is:Error filling print... Error evaluating expression : Source text : net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$F{LOT_LETTERCONDITION_DTL_CONDIT})net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$F{LOT_LETTERCONDITION_DTL_CONDIT}) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:197) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:537) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:505) at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:826) at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:890) at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:871) at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:275) at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:426) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1380) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:692) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:113) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:879) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:782) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:947) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassCastException: oracle.sql.BLOB cannot be cast to [b at BLOB_Test_1220334861077_635142.evaluate(BLOB_Test_1220334861077_635142:164) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:186) ... 18 more Print was not filled. Try using an EmptyDataSource... KINDLY HELP ME - IN SOLVING THIS PROBLEM!!!! Link to comment Share on other sites More sharing options...
deepajain Posted January 24, 2009 Share Posted January 24, 2009 Hi sheshkrish,hav u found the solution of ur prob??i do hv the same prob too..plz tell me the solution of this if u hv. Thanks in advance Post Edited by Deepa Jain at 01/24/09 17:12Post Edited by Deepa Jain at 01/24/09 17:13 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