Jump to content
We've recently updated our Privacy Statement, available here ×
  • Opening PDF of the report in browser directly instead of downloading in 8.1.x


    Dhiraj Pahlani
    • Features: Exporters Version: v8.1 Product: JasperReports® Server

    Problem:
    We have upgraded to JasperReports Server 8.1.1 and are seeing a different behavior when accessing reports with PDF output.

    In previous version of Jaspersoft, end user was able to open the report directly in the browser without downloading it but in the current version of JasperReports Server 8.1.1 we are not able to open the report directly in the browser rather it is being downloaded.

    This is seen with all web browsers (Edge, Chrome and FireFox).

    Is there a Jaspersoft setting that control this behavior?


    Cause:
    The change in behavior was made on purpose because of a security aspect and there are no plans to change this behavior.

    Solution:
    To open the PDF file in the browser, we need to pass suppressContentDisposition as true in the URL. By default it is false.
    File name: ReportExportModel.js (jasperserver-ui/ce/bi-report/src/bi/report/model/ReportExportModel.js)
    Method name: urlOutput
    Replace the below line of code
    return this.url() + '/' + this.get('id') + '/outputResource';
    with
    return this.url() + '/' + this.get('id') + '/outputResource?suppressContentDisposition=true';

    So, the below steps can be followed to achieve the requirement:
    1. Download the required source file from the eDelivery website (for example, TIB_js-jrs_8.1.1_src)

    2. Make the above suggested changes in the mentioned configuration file.

    3. Since we are making JavaScript customizations, we will need to rebuild the scripts using the Webpack approach. For complete steps on customizing JavaScript source code, kindly refer to the section 5.2.3, "Customizing JavaScript Source Code" from our Ultimate Guide.
    https://docs.tibco.com/pub/js-jrs/8.1.0/doc/pdf/TIB_js-jrs_8.1.0_Ultimate-Guide.pdf?id=11

    Kindly note that the change to the current behavior of downloading the file instead of opening in the browser was made on purpose because of a security aspect and we are not planning to change this behavior. To force the browser to open the PDF report, you can follow the above steps but it is not recommended from a security perspective.
    _____________________________________________________________________________________________________________________________________________________________
    Ref. Case #02211031


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