Search results
Suggest a FeaturePDF

Print report

The Report Viewer provides print report option in the toolbar to print a copy of the report. The page setup dialog allows you to set the paper size or other page setup properties. To see print margins, click Print Layout on the toolbar.

You can set values in the Page Setup dialog box for current session only. When you close the report and reopen it, it will have the default values again. The default values of the Page Setup dialog is based on the report properties set in the design view.

View report in print mode

Print margins are displayed in the print layout only. To view report in print mode by default, set the print-mode property to true.

    <bold-report-viewer id="viewer" report-path="sales-order-detail.rdl" report-service-url="/api/ReportViewer" print-mode="true" processing-mode="Remote"></bold-report-viewer>

By default, the Report Viewer renders report in normal layout in which the print margins are not displayed.

To open the print in a new tab of the current browser, set the printOption property to NewTab. By default, it shows the print dialog in the same page.

    <bold-report-viewer id="viewer" report-path="sales-order-detail.rdl" report-service-url="/api/ReportViewer" print-mode="true" print-option="NewTab" processing-mode="Remote"></bold-report-viewer>

The pop-up blocker should be enabled for the page to open the print view in new tab.

Set page orientation and paper size

You can specify the print page paper size and orientation at client-side to change the page setup properties by setting the page-settings property.

The following code example illustrates how to set page orientation and paper size in the Report Viewer for client side.

    <bold-report-viewer id="viewer" report-service-url="/api/ReportViewer" processing-mode="Remote" page-settings="ViewBag.pageSettings">
    </bold-report-viewer>

The following code example illustrates how to set page orientation and paper size in the Report Viewer for server side.

       public ActionResult Index()
        {
            ViewBag.pageSettings = new BoldReports.Models.ReportViewer.PageSettings();
            ViewBag.pageSettings.Orientation = BoldReports.ReportViewerEnums.Orientation.Landscape;
            ViewBag.pageSettings.PaperSize = BoldReports.ReportViewerEnums.PaperSize.Letter;
            return View();
        }

Set report margin

To set margin values to the report page setup, use the Margins property and specify the value to top, right, bottom, and left.

The following code example illustrates how to set report margin in the Report Viewer for client side.

    <bold-report-viewer id="viewer" report-service-url="/api/ReportViewer" processing-mode="Remote" page-settings="ViewBag.pageSettings">
    </bold-report-viewer>

The following code example illustrates how to set report margin in the Report Viewer for server side.

       public ActionResult Index()
        {
            ViewBag.pageSettings = new BoldReports.Models.ReportViewer.PageSettings();
            ViewBag.pageSettings.Margins = new BoldReports.Models.ReportViewer.Margins();
            ViewBag.pageSettings.Margins.Top = 0.5;
            ViewBag.pageSettings.Margins.Left = 0.5;
            ViewBag.pageSettings.Margins.Bottom = 0.5;
            ViewBag.pageSettings.Margins.Right = 0.5;
            return View();
        }

The values set in the margin property is considered as inches input.

Set page height and width

To set height and width values to the report page setup, use the Height and Width properties.

The following code example illustrates how to set page height and width in the Report Viewer for client side.

    <bold-report-viewer id="viewer" report-service-url="/api/ReportViewer" processing-mode="Remote" page-settings="ViewBag.pageSettings">
    </bold-report-viewer>

The following code example illustrates how to set page height and width in Report Viewer for server side.

       public ActionResult Index()
        {
            ViewBag.pageSettings = new BoldReports.Models.ReportViewer.PageSettings();
            ViewBag.pageSettings.Height = 11.69;
            ViewBag.pageSettings.Width = 8.27;
            return View();
        }

The values set in the height and width properties are considered as inches input.

When the report has more images, the browser will send the report stream to the print dialog before the images are completely loaded. To load the print report stream with complete images, you should set the EmbedImageData property to true in OnInitReportOptions as shown in the following code.

    public void OnInitReportOptions(ReportViewerOptions reportOption)
    {
        reportOption.ReportModel.EmbedImageData = true;
    }

Replace the following code sample in the client-side HTML file.

    <bold-report-viewer id="viewer" report-service-url="/api/ReportViewer" processing-mode="Remote" report-path="Product Details.rdl" page-settings="ViewBag.pageSettings">
    </bold-report-viewer>

In this tutorial, the Product Details.rdl report is used, and it can be downloaded from here.

External styles in report printing

While printing report, the external styles are used in the application overrides printable page style and prints output with incorrect alignments. To avoid the external script overriding, set the isStyleLoad property to false, which will print the page using only the Report Viewer styles.

    <bold-report-viewer id="viewer" report-service-url="/api/ReportViewer" processing-mode="Remote" report-path="Product Details.rdl" report-print="onReportPrint">
    </bold-report-viewer>

    <script type="text/javascript">
        function onReportPrint(args) {
            args.isStyleLoad = false;
        }
    </script>

Show print progress

Report Viewer provides events to show the progress information when the printing takes long time to complete.

To show print progress, follow these steps:

  1. Set the print-progress-changed in Report Viewer initialization.
  2. Implement the function and add code samples to show a custom message based on the print progress status as shown in the following code snippet.
    <bold-report-viewer id="viewer" report-service-url="/api/ReportViewer" processing-mode="Remote" report-path="Product Details.rdl" print-progress-changed="onPrintProgressChanged">
    </bold-report-viewer>

    <script type="text/javascript">
        function onPrintProgressChanged(args) {
            if (args.stage == "beginPrint") {
                $('#viewer').ejWaitingPopup({ showOnInit: true, cssClass: "customStyle", text: "Preparing print data.. Please wait..." });
            }
            if (args.stage == "printStarted") {
                var popupObj = $('#viewer').data('ejWaitingPopup');
                popupObj.hide();
            }
            else if (args.stage == "preparation") {
                console.log(args.stage);
                if (args.preparationStage == "dataPreparation") {
                    console.log(args.preparationStage);
                    console.log(args.totalPages);
                    console.log(args.currentPage);
                    if (args.totalPages > 1 && args.currentPage > 1) {
                        var progressPercentage = Math.floor((args.currentPage / args.totalPages) * 100);
                        if (progressPercentage > 0) {
                            var popupObj = $('#viewer').data('ejWaitingPopup');
                            popupObj.setModel({ text: "Preparing print data.." + progressPercentage + " % completed.. Please wait..." });
                        }
                    }
                }
            }

            args.handled = true;
        }
    </script>

Remove empty spaces in printing

The extra blank page is created when the body of your report is too wide for your page. To make the report appear on a single page, all the content within the report body must fit on the physical page, and the body width should be as the following formula.

Body Width <= Page Width - (Left Margin + Right Margin)

For more details about removing the empty pages in the report while designing, refer to the knowledge base article of report page sizing.