Is there a way to specify the size of the HTML report as percentages, like width = "90%"
? Or to ensure in some other way, that the report's width, when exported to HTML, is a certain percentage of the user's screen?
I don't mind creating an extra template, or just export only a chart as an image.
I'm using Jasper Reports Version 6.9.0.
Jasper report export aims for pixel perfect (printable) output, that's why by default the size will correspond in pixel to the actual width of your report no matter what size of the browser window is.
Jasper reports
HTMLExporter
to achieve this creates a table with 3 columns, first empty columnwidth="50%"
, second column width in px as width of your report and third empty column again withwidth="50%"
. This will center the result and the width of the report will equal the width indicated in jrxml.If you export from java you can override this behaviour and set your own html header and footer.
Example
Basically the change from default html header and footer that I made is
Added
.jrPage
style to override the pixel width and instead change to 90% width.Changed % of the two side columns from
50%
to5%
This will create a dynamically sized html that is centered and takes 90% of available window size.
Example how to automatically scale image in this case generated by a chart
Considering the jrxml in this question How can I export report to PDF/A-1a, PDF/A-1b?
Add
net.sf.jasperreports.export.html.class
to the chart elementAdd some CSS in HTML header
Do note however that the image is only "re-scaled" hence it will keep it's original resolution.