开发者

displaying really huge images in jasper reports

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜