ActiveReports 14
ActiveReports 14 User Guide / Print Reports / Print in JS Viewer
In This Topic
    Print in JS Viewer
    In This Topic

    JS Viewer provides several options for printing a report. This topic describes several ways in which a report can be printed in JS Viewer.

    Print with Preview

    Print report when the report is completely loaded in the viewer, using print() method.

    index.html
    Copy Code
    var viewer;
    function loadViewer() {
        viewer = GrapeCity.ActiveReports.JSViewer.create({
            element: '#viewerContainer',
            reportID: 'RdlReport1.rdlx',
            documentLoaded: () => viewer.print()
        });
    }
    

     

    Print without Preview

    Print report without previewing using 'global' print() method. This is same as the default button in JS Viewer, but without showing report preview.
    index.html
    Copy Code
    GrapeCity.ActiveReports.JSViewer.print({ reportID:'RdlReport1.rdlx'});
    

     

    Preview Report and Print to PDF

    Open the report and export it to PDF with PrintOnOpen parameter set to 'true'. In this case, the exported PDF opens in new window of the browser, and the print dialog is displayed.

    index.html
    Copy Code
    var viewer;
    function loadViewer() {
        viewer = GrapeCity.ActiveReports.JSViewer.create({
            element: '#viewerContainer',
            reportID: 'RdlReport1.rdlx',
            documentLoaded: () => viewer.export('Pdf', null, true, { PrintOnOpen: 'true' })
        });
    }
    

     

    Print to PDF

    Export the report to PDF using 'global' export() method and enable the PrintOnOpen option. In this case, the report is not opened.
    index.html
    Copy Code
    GrapeCity.ActiveReports.JSViewer.export({
        reportID: 'RdlReport1.rdlx', exportType: 'Pdf', settings: { PrintOnOpen: 'true' },
        callback: (args) => { window.open(args) }
    })
    

    Note:

    • For Section Reports, use OnlyForPrint instead of PrintOnOpen (for backward compatibility). For Page and RDL reports (.rdlx), anyone of PrintOnOpen or OnlyForPrint can be used.
    • Use latest versions of Chrome, Firefox, and Chrome-based Edge for the described print features to work correctly.