Is it possible to modify the height of detail band dynamically in jasper report? Because in my application i need to create pdf document.I have used one main document inside detail band of that main document i used one subreport. Sub report will take java bean as data source. This java bean return a list of field. So if we fixed the size of band then some time all values are not stretch in the document. Is it possible to change the detail band dynamically.
6
votes
2 Answers
7
votes
JasperDesign jasper = JRXmlLoader.load(objeto.getRealPath("/reports/reportTaxType.jrxml"));
JRDesignBand banda = (JRDesignBand) jasper.getDetail();
banda.setHeight(2000); //YOU CAN SET THE SIZE THAT YOU WANT
JasperReport report2 = JasperCompileManager.compileReport(jasper);
JasperPrint print = JasperFillManager.fillReport(report2, parameters, ds);
6
votes
You can use JRXmlLoader.load()
to create a JasperDesign
object out of template file. Use a method like getPageHeader()
on the result to retrieve the band you want and cast the return value to JRDesignBand
: returned object implements JRBand
, but for JasperDesign
it is always a JRDesignBand
. In the JRDesignBand
class there is a setHeight()
method.
Finally, use JasperCompileManager.compileReport()
to create a JasperReport
from the (now modified) JasperDesign
.