Switching page orientation in ireport

xain picture xain · Jun 10, 2012 · Viewed 12.5k times · Source

I've read there's no way to handle mixed orientations natively using iReport, however reading the documentation I wonder if by using JRDefaultScriptlet's beforePageInit() it could be accomplished somehow. In my case there's a portrait front page, as many landscape pages as there's data to populate them, and a last frontal page.

On the other hand does anybody know:

  • If this is a feature to be supported in the near future
  • If there's an alternative that does as requested and generates a jasper-compliant xml file

Thanks in advance.

Answer

Jacob Schoen picture Jacob Schoen · Jun 13, 2012

So I decided to play around with iReport and see what options there where for this. Turns out it is sort of possible to pull off, with some effort and imagination. This is assuming your first page is in the Title Section, and your Last Page is in the summary section.

  1. Create your report in landscape mode.

  2. Under Report Properties in iReport set Title on New Page and Summary on New Page to true.

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

  4. Add your static text fields into the appropriate section.

  5. Now for each static text field you need to set the Rotate property to Left (well it could actually be Right, the point is they all need to be the same.

  6. Of course add the all the other fields you want into the appropriate bands for page header, data, etc.

  7. Export your report.

Note: if you have any images that need to go into the Title or Summary Section your will need to rotate them appropriately 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 that would make life to easy.

Also if you do not set the properties listed in step 2 you will not be able to set the height of the Title and Summary bands to the appropriate width. If you are using a different size paper and/or margins the easy way to figure out the max size (which is what you will need) is to set the height of the band to a very large number. It will then popup and tell you it is to large, and what the max size actually is.