views:

187

answers:

1

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.

+1  A: 

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.

doublep