画像データをInputStreamで受け渡すことによって、Javaプログラム側で画像を指定できる
iReportで、画像のプロパティを設定する
* Image Expression => $P{imgsrc}
* Image Expression Class => java.io.InputStream
パラメータの設定をする
* Parameter name => imgsrc
* Parameter class type => java.io.InputStream
Javaプログラムでは、パラメータとして imgsrc に 画像のInputStreamを指定する
String imgPath = “images/xx.gif”; //画像ファイルの場所を指定
InputStream imgsrc = new FileInputStream(imgPath);
Map paramMap = new HashMap();
paramMap.put(“imgsrc”, imgsrc);
//テンプレートXMLのコンパイル
JasperReport jasperReport = JasperCompileManager.compileReport(templatePath);
//データの動的バインド
JasperPrint print = JasperFillManager.fillReport(jasperReport, paramMap, new JREmptyDataSource());
//PDFへ出力
JasperExportManager.exportReportToPdfFile(print, destPath);