Jump to content
Changes to the Jaspersoft community edition download ×

JasperPrint and output formats


jmbaker

Recommended Posts

Hello,

 

If I have a JasperPrint object, I can export it using the various exporters provided with Jasper Reports. However, formatting (such as multi page output, etc.) is the kind of thing one wishes to change given an output format. For example, paginated output isn't something I generally wish to see if I export to HTML (I'd like to see one big table), however if I output to a PDF then pagination is a must.

 

Saying that, paginated HTML output would be handy if we could output one page at a time (and therefore support 'previous' and 'next' functions in the browser). But we'll park that thought for now.

 

Therefore, using a JasperPrint object, can I output to HTML without pagination and PDF with pagination?

 

If not, would the developers of Jasper consider breaking up the generated report from the view? I appreciate this isn't a five minute task, but could it be kept in mind?

 

Thanks,

 

 

John

Link to comment
Share on other sites

  • Replies 12
  • Created
  • Last Reply

Top Posters In This Topic

I don't have an example to hand but I don't think it works the way in which you suggest. The exporter exports the JasperPrint object, and it would appear that if the JasperReport had pagination set to true, then the JasperPrint is a paginated report (and this can not be changed).

 

Surely a Jasper report guru can comment on this query? The way in which this currently operates should be obvious to someone who knows the code well.

 

 

John

Link to comment
Share on other sites

I'll step in and try to clear the confusion.

 

Generated reports are indeed paginated, as John stated. The HTML exporter outputs (by default) all the report pages on a single HTML "page", and I think this is why Sanda says that the HTML export is not paginated. However, the HTML output is composed of report pages (with headers, footers and all) and in this sense it is paginated.

 

Back to John proposal now.

 

A generated report is composed of pages, and changing this paradigm would not be an easy thing to do.

 

The JasperReports engine performs many actions that depend on the pagination: page totals, repeated group headers, unbreakable bands and so on. If we move the pagination to the export phase, all these actions will have to be performed at that phase, but this would not simply consist of moving a bunch of code for one place to the other since the export process operates in a different context that the fill phase.

 

There are several features that provide solutions for some scenarios in which pagination is not required:

  • There's a flag that instructs the engine to ignore pagination when filling a report. The resulting report will be comprised of a single long page.

     

    One could use this approach and then manually paginate the generated report if paginated export is also required. No change in the JR library is required to implement such an external pagination.

Export filters have been recently implemented. One could use such a filter to exclude the page footers and headers from showing up in the generated report.

 

This was primarily intended to allow data-centric XLS export, but under certain conditions it can be used to achieve unpaginated output from other exporters as well.

[/ul]

 

These being said, I think I can say that we are not currently considering removing the pagination from the fill process. If you have more arguments, proposal or any kind of feedback we'd be glad to hear it.

 

Regards,

Lucian

Link to comment
Share on other sites

PS:

 

Saying that, paginated HTML output would be handy if we could output one page at a time (and therefore support 'previous' and 'next' functions in the browser). But we'll park that thought for now.

 

I'm not sure what you meant by that. How's not able to output one page at a time? JasperReports supports that.

 

Regards,

Lucian

Link to comment
Share on other sites

  • 3 weeks later...

# There's a flag that instructs the engine to ignore pagination when filling a report. The resulting report will be comprised of a single long page.



One could use this approach and then manually paginate the generated report if paginated export is also required. No change in the JR library is required to implement such an external pagination.

 

Lucianc,

 

Hello & good day,

 

I was hoping you may evaluate a little more as to how/where this flag is accessed. I have created a web-app similar to the sample in the jasperserver2.0.1 distr. I need html exported format to be paginated.

Is this flag included as part of the exporter?

 

 

Also,

I have been studying the behavior of exporting from within JasperServer, could you direct me to some useful information as to how the pagination functions there?

 

For example:

I choose to run a report stored in the repository (in html format) and the result is a .jsp containing the report, as well as the export options (pdf, xls, csv, etc.) and page navigation.

 

From what I can see, the page navigation is using .js/Ajax to navigate thru pages. I would like to know more details about this process (if you could).

 

Thanks so much!

Jasper Reporting Rules!

Link to comment
Share on other sites

  • 3 weeks later...

I'll try to answer some questions from the last posts.

 

  • The pagination flag is set when filling the report. I understand that in some cases it would be useful to set it at export time, but that's not possible given the way JasperReports currently works.

No documentation that describes how the JasperServer code works is available. However, the code itself is available.

You don't need to call JRHtmlExporter.exportPage() directly. You can export a single report page by using the JRExporterParameter.PAGE_INDEX export parameter.[/ul]

 

Regards,

Lucian

Link to comment
Share on other sites

Thank you kindly Lucianc,

 

I have discovered the use of the PAGE_INDEX parameter.

 

No documentation that describes how the JasperServer code works is available. However, the code itself is available

 

Are you referring to the source of the download? I have viewed it several times. I am using different frameworks, and need some guidance as to how the source would relate...

 

I'm not asking you to write the code for me, but I do need some direction as to how I should implement my code.

 

Thank you for the reply.

Link to comment
Share on other sites

I'm not sure what kind of guidance I could provide you.

 

For instance, if you want to display a (HTML) paginated report, things are simple conceptually: you fill the report into a JasperPrint object, keep this object on the session and when the user requests the next page, you retrieve the JasperPring object from the session, export the requested page to HTML and write the result in the response. If the user wants PDF/XLS/etc output, you get the JasperPrint object from session and export it to the desired format.

 

How would this translate into code for your application is not so easy to say.

 

Regards,

Lucian

Link to comment
Share on other sites

you fill the report into a JasperPrint object, keep this object on the session and when the user requests the next page, you retrieve the JasperPring object from the session, export the requested page to HTML and write the result in the response.

 

I see what you mean... (sample)

 

I have the Ajax functionality implemented now also, thanks to the PAGE_INDEX parameter.

 

Thanks again Lucianc!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...