Displaying Really Huge Images in Jasper Reports

The java app generates an image (basically an org chart) for the jasper report. As the organization charts go, it is impossible to determine the final output size of the image. Also, the image output may grow too much that cropping the image is useless.

Is it possible for the jasper report to dynamically resize the image element without splitting the images?

+2


a source to share


2 answers


Try the following:



<image scaleImage="ReatinShape" hAlign="Center"> 
    <reportElement x="100" y="150" width="600" height="150"/> 
    <graphicElement/> 
    <imageExpression class="net.sf.jasperreports.engine.JRRenderable">
     <![CDATA[new com.onbarcode.barcode.jasper.JasperRenderer(yourImage)]]></imageExpression> 
</image>

      

+1


a source


I haven't tested this myself, but it should work. Get an image element from a design, resize it, and then compile the resized design.

BufferedImage img = ImageIO.read(new File(wo_image_path));
height = img.getHeight();
width = img.getWidth();         
jasperSubDesign = JasperManager.loadXmlDesign(context.getRealPath("/WEB-INF/reports/decoration_sheet_header.jrxml"));

JRDesignImage image = (JRDesignImage)jasperSubDesign.getPageHeader().getElementByKey("wo_image");

image.setX(3);
image.setY(69);
image.setHeight(new Long(height - Math.round(height*.35)).intValue());
image.setWidth(new Long(width - Math.round(width*.35)).intValue());

JasperCompileManager.compileReportToFile(jasperSubDesign, context.getRealPath("/WEB-INF/reports/decoration_sheet_header.jasper"));

      



From Jasperforge

0


a source







All Articles