aspose file tools*
The moose likes Other Open Source Projects and the fly likes Jasper Report- JRException: Image read failed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasper Report- JRException: Image read failed" Watch "Jasper Report- JRException: Image read failed" New topic
Author

Jasper Report- JRException: Image read failed

Prabhat Kumar
Greenhorn

Joined: Jan 25, 2007
Posts: 27
Dear All,

I am facing a problem in loading of images in PDF using JasperReport(itext2.1.3). I have created a jasperreport page which print in specified no of pages as per user choice with same content. In the page, images are used which is set as InputStream as jasper report field.
If report is getting prepared for one page, then image gets loaded properly and there does not have any problem with PDF preparation but in case of multiple pages, below exception gets raised:

net.sf.jasperreports.engine.JRException: Image read failed.
at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:77)
at net.sf.jasperreports.engine.util.JRImageLoader.loadImage(JRImageLoader.java:248)
at net.sf.jasperreports.engine.JRImageRenderer.getImage(JRImageRenderer.java:354)
at net.sf.jasperreports.engine.JRImageRenderer.getOnErrorRendererForImage(JRImageRenderer.java:307)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1160)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:675)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:641)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:536)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:323)

Plese help to solve this problem.

Thanking you in advance,
Prabhat Kumar
visitor visitor
Greenhorn

Joined: Sep 11, 2009
Posts: 1
You have probably IntutStream not ok,
Try to test it before you add it to Jasper Report parameters map

import java.awt.Image;
import javax.imageio.ImageIO;

private boolean isReportImageOK(InputStream logoFile) //throws Exception
{
boolean isImageOk = false;

Image image = null;
try
{
image = ImageIO.read(logoFile);
logoFile.reset();
}
catch (IOException e)
{
logger.error("IO exception ");
//throw new Exception(e);
}

if (image == null)
{
logger.error("Image incorrect ");
}
else
{
logger.error("Image correct ");
isImageOk = true;
}

return isImageOk;
}


if result will be "false" then you can switch to another Image.

Best regards,
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

visitor visitor, please see your PM for an important Administrative message.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
qiongchun chen
Greenhorn

Joined: Nov 24, 2009
Posts: 1
I fixed this error by setting the image control's property "on error type" to "Blank".
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

And welcome to Javaranch qiongchun chen!
David Barrera
Greenhorn

Joined: Sep 27, 2013
Posts: 1
I solved this problem setting true on using cache property



Prabhat Kumar wrote:Dear All,

I am facing a problem in loading of images in PDF using JasperReport(itext2.1.3). I have created a jasperreport page which print in specified no of pages as per user choice with same content. In the page, images are used which is set as InputStream as jasper report field.
If report is getting prepared for one page, then image gets loaded properly and there does not have any problem with PDF preparation but in case of multiple pages, below exception gets raised:

net.sf.jasperreports.engine.JRException: Image read failed.
at net.sf.jasperreports.engine.util.JRJdk14ImageReader.readImage(JRJdk14ImageReader.java:77)
at net.sf.jasperreports.engine.util.JRImageLoader.loadImage(JRImageLoader.java:248)
at net.sf.jasperreports.engine.JRImageRenderer.getImage(JRImageRenderer.java:354)
at net.sf.jasperreports.engine.JRImageRenderer.getOnErrorRendererForImage(JRImageRenderer.java:307)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1160)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:675)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:641)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:536)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:323)

Plese help to solve this problem.

Thanking you in advance,
Prabhat Kumar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jasper Report- JRException: Image read failed
 
Similar Threads
JasperReport
Error when exportReportToPdfFile
Jasper report - Change Page Orientation
Problem with jasper report -loading stream
Jasper subreport not getting displayed when Jasper print is called twice