开发者

displaying really huge images in jasper reports

开发者 https://www.devze.com 2022-12-29 11:23 出处:网络
My java application is generating an image(basically an org chart) for a jasper report. As org charts go, there\'s no way one can determine the final size of the image output. Also the image output ca

My java application is generating an image(basically an org chart) for a jasper report. As org charts go, there's no way one can determine the final size of the image output. Also the image output can grow too large, that cropping the image is useless.

Is it even possible to have the jasper report to dynamically resize it's image element withou开发者_运维技巧t splitting the images?


Try this:

<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>


I've not tested this myself, but it it supposed to work. Get the image element from the design, change it's size, then compile the altered 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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号