Jump to content
We've recently updated our Privacy Statement, available here ×
  • Report pagination with Visualize.js and TIBCO JasperReports® IO Javascript API


    stasp
    • Version: v7.1 Product: JasperReports® Server

    Use case

    Sometimes you want to render a paginated report when running it from TIBCO JasperReports® Server web UI, but then have the same report non-paginated when embedded into your web application. Or embed a paginated version into a web app, but then export the output in non-paginated format into, say, XLSX. Or vice versa.


    Solution for Visualize.js

    For any of the scenarios above you can use an ignorePagination property when either rendering or exporting your report via API.

    When the property is set to true, entire report will render as one page.

    When the property is set to false, report will get split into multiple pages.

    In the example below the embedded report will render as one page, regardless of how it is configured in JRXML or on the server:

    function (v) {
        var report = v.report({
            resource: "/public/Samples/Reports/AllAccounts",
            container: "#container",
            ignorePagination: true,
            error: function(e) {
                alert(e);
            }
        });

    And this is an export call which ensures that the output file is paginated:

            report
                .export({ 
                    outputFormat: "pdf",
                    ignorePagination: false,
                })

    Here is a sample in JSFiddle that demonstrates both of the above:

    http://jsfiddle.net/Stas_P/nk3rdb54/

    Notes on TIBCO JasperReports® IO Javascript API

    With JasperReports® IO, the ignorePagination property is only available when embedding a report. When performing an export this property is ignored (at least in the current version 1.0.0).

    The output file will have the same pagination as you specified for ignorePagination property at the rendering time. Or if none is specified, it will have the pagination of the report itself (false by default).

    Notes on Documentation

    Both JasperReports® Server Visualize.js Guide and JasperReports IO User Guide have somewhat misleading information on paginating report exports via the API. Both of the guides have examples with a property named paginated. THIS IS INCORRECT. E.g.:

    report
        .export({
            outputFormat: "xls",
            pages: "1-10",
            paginated: true
        })

    The correct version of this call in Visualize.js will look like this:

    report
        .export({
            outputFormat: "xls",
            pages: "1-10",
            ignorePagination: false
        })

    For JasperReports IO, as mentioned above, there is no way to control pagination during export. It's only possible during embedded rendering.

    TIBCO Jaspersoft® docs team is aware of this documentation issue, and the guides should be fixed in the next releases of the corresponding products.


    User Feedback

    Recommended Comments

    There are no comments to display.



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