How to generate PDF reports that spans multiple pa

2019-02-14 08:52发布

问题:

I have to generate PDF reports with many (defined at runtime) columns. These reports may span multiple pages horizontally when user selects many fields to show. I'm using DynamicJasper and could successfully generate dynamic reports when all the columns fit in one page. When they don't, report is cropped and only a few columns are shown. I've tried changing the page width in runtime and report is not cropped, but it can't be printed correctly because page size is not standard. Which is the right way to generate this kind of reports?
The goal is to split big tables in multiple pages if they exceed page width, like when printing a spreadsheet. Is it possible to achieve it using JasperReports?

Thanks in advance.

回答1:

Since you also want to print the report, you will have to work from standard print sizes (such as A4 and A3) and a landscape orientation since width is the issue.

To get the most possible on a page: 1) Use smaller fonts 2) Use landscape page orientation 3) Use a larger page size (A3, A2...) as long as your printer can handle it

If you still can't fit on a page, think about how you want to lay out the result - what would you like to see if someone gave a really big table to you? You will need to split the table into some columns for one page and some columns for another.

Hope that helps.