Printing Reports from ReportViewer
At run time, application users can use the print commands on the ReportViewer toolbar to open a Print dialog box, preview the report in print layout, and configure page setup prior to printing.
Print support varies depending on whether you are using the Web server control or Windows Forms control.
The ReportViewer Windows Forms control uses the print functionality of the client operating system. Clicking the Print icon on the report toolbar opens the common Print dialog box, initialized with the printers configured on the client computer.
The ReportViewer Web server control provides an ActiveX print control that you can use in Internet Explorer instead of browser print functionality. In contrast with browser print functionality, the print control allows you to print all of the pages of a paginated report without the other elements in the Web page, such as the ReportViewer interface itself, as well as the page information that the browser add to the printout, such as the page title, page URL, and print date.
The ReportViewer Web server control, when used with client report definition (.rdlc) files, does not provide built-in print support. Although you can use the browser print functionality, you might achieve better results if you export the report to PDF or Excel and then print from the PDF viewer or Excel.
To learn how to print reports programmatically, see Walkthrough: Printing a Local Report without Preview.
Previewing a Report and Setting Page Sizes
The ReportViewer toolbar in the Windows Forms control includes commands for viewing a report in print layout and setting page sizes. When you click Print Layout, the ReportViewer toolbar is updated to show just the commands that you can use during preview. Print Layout is a toggle command. You can switch between print layout mode and interactive mode by clicking this button. When you click Page Size, you can specify page dimensions that are used only for print output. The page dimensions are initialized with values from the report definition, but you can override the values. You cannot save the values with the report.
The Web server control supports the same preview and page size functionality, but it is provided through the print control rather than as separate commands on the toolbar. To view the print layout, click the Print button in the ReportViewer toolbar, then click the Preview button in the Print dialog box. You can then control the page size by clicking the Margins button.
Configuring the Print Control for Server Reports Using the ReportViewer Web Server Control
The ReportViewer Web server control provides an ActiveX print control. This control downloads automatically the first time the Print button on the ReportViewer toolbar is clicked, and is installed on the client computer. If the user does not install the control, the Print button cannot be used. After the control is installed, users can use the print control to print reports in the ReportViewer Web server control.
Depending on browser settings, the user may need to configure the browser to enable an ActiveX control download. To configure Internet Explorer to allow ActiveX control downloads, follow these steps:
In Microsoft Internet Explorer, from the Tools menu, choose Internet Options, and then click the Security tab.
Select the appropriate Web content zone (for example, Restricted sites), and then click Sites.
Type the URL of the Web application that contains the ReportViewer control.
Click Add, and then click OK.
Click the Custom Level button for the Web content zone. Scroll to the ActiveX controls and plug-ins node.
Click Prompt for Download signed ActiveX controls, and then click OK.
Copyright © 2012 by Microsoft Corporation. All rights reserved.