How to create Cover in a Report using iReport

Asked

Viewed 892 times

5

I am using iReport 5.5.2 and have tried in many ways to add a cover to the report, which is necessary but unsuccessful. I tried adding the isTitleNewPage attribute to the iReport Title band, but it didn’t work and I looked for some attribute to start a band on a new page and then the rest on another page and it doesn’t work. I saw in a forum, that I do not remember the name, a user stating that solved the problem by creating two separate PDF files and then uniting the two with iText, but I believe this is POG.

1 answer

5


When I had the need to add any pages in reports or even join several reports, the way was to join the documents with iText.

This is not POG! POG is using a tool for a different purpose than the one it was designed for.

Jasperreports (iReport is only the editor) was a project to generate reports from data sources and not documents containing text. Already iText is designed to create and manipulate PDF files. Therefore, nothing fairer than leaving each tool with its function.

On the other hand, I did a brief search to see if Jasperreports' people could have implemented anything specific about this and I came to a blog which shows a code snippet that allows two reports to be merged. I haven’t tested the solution, but if it works you can create another report that is just the cover and join with the report that contains the data.

See the code snippet:

JasperPrint jp1 = JasperFillManager.fillReport(url.openStream(), parameters,
                    new JRBeanCollectionDataSource(inspBean));
JasperPrint jp2 = JasperFillManager.fillReport(url.openStream(), parameters,
                    new JRBeanCollectionDataSource(inspBean));

List pages = jp2 .getPages();
for (int j = 0; j < pages.size(); j++) {
    JRPrintPage object = (JRPrintPage)pages.get(j);
    jp1.addPage(object);
}
JasperViewer.viewReport(jp1, false);

Obviously it would be necessary to adapt the example and check if its API version is compatible with this method.

  • @utiluiz thanks for the reply, you saving my reports again. The question of joining the reports and being Pog, I said why I thought iReport already had an option to add cover, ignorance of me about the tool. One solution I found was to put the cover image in the title, and the image took up a whole page. With your explanation what I did is a ploy to work.

  • @adelmo00 Yeah, there really are some techniques putting up images or a subreport, but I wouldn’t use them because they’re really gambiarras. Well, gambiarra or not, the important thing is that meets your goals. ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.