How to set margins to jasper report in java!
I have reports.jasper with margins,but when print I must change margins!
JasperPrint.setTopMargins(myMarginsValue)
doesn't work!!!
I use JRPrintServiceExporter
to send to the printer!
Current code:
InputStream reportStream = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/reports/" + "myReport"+".jasper");
JasperReport template = (JasperReport) JRLoader.loadObject(reportStream);
template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
Load the jrxml (note not the .jasper) into the JasperDesign using the JRXmlLoader
Then fill it and export it as you wish.
Naturally textField may be out side of design, band may not fit the page height if you increase your margins to much, this needs to be attended to as appropriate.
This is another similar question with full code if the purpose is moving layout to adapt to pre-printed form: How can I move the whole layout to adapt to pre-printed form on different printers