我的Java應用程序正在生成碧玉報告的圖像(基本上是組織結構圖)。隨着組織結構圖的推進,人們無法確定圖像輸出的最終大小。此外,圖像輸出可能會變得太大,裁剪圖像無用。在jasper報告中顯示真正巨大的圖像
是否有可能讓碧玉報告動態調整它的圖像元素而不拆分圖像?
我的Java應用程序正在生成碧玉報告的圖像(基本上是組織結構圖)。隨着組織結構圖的推進,人們無法確定圖像輸出的最終大小。此外,圖像輸出可能會變得太大,裁剪圖像無用。在jasper報告中顯示真正巨大的圖像
是否有可能讓碧玉報告動態調整它的圖像元素而不拆分圖像?
試試這個:
<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>
我沒有這個測試自己,但它應該工作。從設計中獲取圖像元素,更改其大小,然後編譯更改後的設計。
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"));
一個愚蠢的問題... 什麼樣的階級是yourImage參數?這是路徑嗎?或bufferedimage 順便說一句,我習慣於在iReport中開發Jasper報告。 – xilver 2010-05-05 10:49:11
這是您的報告收到的圖像對象作爲輸入。 – 2010-05-05 15:19:00