rinsha.mohammed Posted February 25, 2021 Share Posted February 25, 2021 Hi All,I need to display Images which comes from database and it's a byte array.I am using Jasper 6.16.0 .I initially tried to get the Image as InputStream in Japser. InputStream logo = new ByteArrayInputStream(imagebytes) - here logo is my input variable for imageSInce I am using JsonQLDataSource in My Java for JasperFillManager.fillReport as below : InputStream inputStream = new ByteArrayInputStream(mapper.writeValueAsBytes(myJsonDto)); JsonQLDataSource jsonData = new JsonQLDataSource(inputStream); final JasperPrint print = JasperFillManager.fillReport(report, parameters, jsonData);[/code] In Japser I gave <field name="logo" class="java.io.InputStream"/>[/code] <band height="125" splitType="Stretch"> <image onErrorType="Blank"> <reportElement x="74" y="33" width="50" height="50" uuid="e93df5ef-176d-436b-a58f-ddcb0d7f6f3c"/> <imageExpression><![CDATA[$F{logo}]]></imageExpression> </image> </band>[/code]But I am not getting my Image Displayed. When I debugged my code I could see that the image variable 'logo' is going empty in Datasource. So I need a loution for this issue, when inputstream is going in another inputstream! Also I tried the solution : https://community.jaspersoft.com/questions/541551/loading-byte-array-database-and-displaying-it-image , there also I didn't get Image displayed. Could anyone please help on this !! Link to comment Share on other sites More sharing options...
Solution rinsha.mohammed Posted March 24, 2021 Author Solution Share Posted March 24, 2021 Finallly I myself found the solution. When inputstream is going in another inputstream the inner inputstream is getting empty. SO I changed the datasource to JRBeanCollectionDataSource .Now it is working fine ! 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