Switch page orientation in ireport

I didn’t read any way there to handle mixed orientations initially using iReport, however, after reading the documentation, I wonder if it is possible to use JRDefaultScriptlet beforePageInit () somehow. In my case, there is a front page with a portrait, so many landscape pages where there is data to fill them, and the last frontal page.

On the other hand, does anyone know:

  • If it is a feature that will be supported in the near future
  • If there is an alternative that runs on demand and generates a jasper-compatible XML file

Thanks in advance.

+4
source share
2 answers

So, I decided to play with iReport and see what options are there, where for this. It turns out that this is a kind of possible removal with some effort and imagination. This assumes that your first page is in the section section, and your Last page is in the resume section.

  • Create a report in landscape mode.

  • In the Report Properties section of iReport, set Title on New Page and Summary on New Page to true.

  • Assuming you are using a standard 8.5 "X 11" page with all margins set to 20, set the height of the Title and Summary sections to 572.

  • Add your static text fields to the appropriate section.

  • Now for each static text field you need to set the Rotate property to Left (well, in fact it can be Right , the point is that they should all be the same.

  • Of course, add all other fields to the appropriate bands for the page title, data, etc.

  • Export the report.

Note If you have images that need to go to the "Title" or "Summary" section, you need to rotate them accordingly outside of iReport and save it. Then set the rotated image as the image in the report. Unfortunately, the image tag does not seem to have a rotate property, as this will make life easier.

Also, if you do not set the properties listed in step 2, you cannot set the height of the title bar and summary to the appropriate width. If you use paper of different sizes and / or margins - an easy way to determine the maximum size (which you need) is to set the strip height to a very large number. Then it will appear and tell you that it is large, and what is the maximum size actually.

+3
source

There is no support for mixed landscape and portrait submission, in the future they will add an object call to JasperBook or something like that, where you can easily add different subtitles of different orientations, but at the moment you are simulating this by making different reports and join them before their show.

those.

// Create reports separately

  InputStream report1 = (InputStream) getClass().getResourceAsStream("/com/app/jasper/reportPortrait.jasper"); InputStream report2 = (InputStream) getClass().getResourceAsStream("/com/app/jasper/reportLandscape.jasper"); InputStream report3 = (InputStream) getClass().getResourceAsStream("/com/app/jasper/reportPortrait.jasper"); JasperPrint jasperPrint = JasperFillManager.fillReport(report, map, conn); JasperPrint jasperPrint2 = JasperFillManager.fillReport(report2, map, conn); JasperPrint jasperPrint3 = JasperFillManager.fillReport(report3, map, conn); JRPdfExporter exp = new JRPdfExporter(); 

// Add JasperPrint objects to ArrayList

  List list = new ArrayList(); list.add(jasperPrint); list.add( jasperPrint2 ); list.add(jasperPrint3); 

// And ask the exporter to join the list of reports.

  exp.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list); exp.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream()); exp.exportReport(); 

I do this in my reports and it works. Good luck

+2
source

All Articles