Jump to content
We've recently updated our Privacy Statement, available here ×

how to set isIgnorePagination without report recompilation?


xorcus

Recommended Posts

Hi there,

I'd like to create a pre-compiled report which can be both rendered on-screen (without pagination), and exported to pdf (with pagination). I found out that pagination is controlled with isIgnorePagination attribute in jasperReport tag.

Is it possible (and how) to set value of isIgnorePagination attribute from Java code (e.g. using parameters) without recompiling the report?

Thanks, xorcus

 

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Just doing a quick post to let you know that yes, this is possible and works extremely well.  I am not in the office and this is a reminder for me follow up tomorrow on how to set the value programatically prior to executing the compiled report, no recompile needed.

Once you set the pagination and execute, report can conditionally print based on intended output, it's a little bit more work designing each report but the outcome is you only need 1 report definition which will then support printing with or without pagination and don't have to maintain 2 copies.  For my reports, if i display on screen in HTML then I disable all pagination,  if the output is PDF or WORD etc, then i assume the intent is for printed content so the report has headers, footers with page numbers dates etc..  best of both worlds.

Co-incidentally,  in my implementation we execute the report and store the print object in a database, we then built a viewer which renders default html and allows the user to select various export formats such as PDF, WORD Etc.  we then run the print object through the render engine in the appropriate format.   Rendering print objects to different output formats is lightweight compared to generating the intial print object so quick access to various formats,  the alternative is that you generate the report in HTML which depending on the report could be lengthy, then if you want to download as PDF you have to re-execute again, separating print object from render means you only have the gather the data once and then can output in whatever format you require. 

 

Link to comment
Share on other sites

Yes this can be done.  I generate reports for Excel and PDF and use the following to enable/disable pagination.

        if (report format is xls) {
            params.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);
        }
        else if (report format is pdf) {
            params.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.FALSE);
        }

then pass the parameter map (params) to the fill manager when creating the JasperPrint object.

Hope this helps?

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...
  • 1 year later...
I wish someone would answer this. I have the same question, where does this code go. I'm using iReport and/or Studio. I'd like to give the user the option when running the report. I see similar posts that give this type of Java code, and it makes sense. But I have no clue how to implement it.
Link to comment
Share on other sites

  • 2 years later...

$params->put("IS_IGNORE_PAGINATION",false);

 

as you set parameters value like that only pass the value to this parameter.

in your code of generating the pdf or excel file insert this code as per your condition.

 

same as the parameter passing to the report.i have done it its working. IF some one know main jasper data change

 

how to change margin in this data. i have change the isIgnorePagination.

I am only able to change isIgnorePagination because its a parameter you can check in iReport. please let me know if you find anything

 

Link to comment
Share on other sites

$params->put("IS_IGNORE_PAGINATION",false);

as you set parameters value like that only pass the value to this parameter.
in your code of generating the pdf or excel file insert this code as per your condition.

same as the parameter passing to the report.i have done it its working. IF some one know main jasper data change
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="iRpt_InvoiceAndPayment_MainRpt" language="groovy" pageWidth="1008" pageHeight="5000" whenNoDataType="NoDataSection" columnWidth="1008" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isIgnorePagination="true" uuid="5f68476c-1cc7-435d-b655-ffdc551ccf22">

how to change margin in this data. i have change the isIgnorePagination.
I am only able to change isIgnorePagination because its a parameter you can check in iReport. please let me know if you find anything

 

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...