Crystal Reports Client Side Printing without the Viewer
This document contains instructions that allow the Crystal Reports in a web application to print client-side without the viewer being visible to the end user.
In many cases, a web application will have the requirement of client side printing of a Crystal Report. Problem with direct print to a client printer is that by definition there will be no user intervention. IE (or any other browser) does not allow this as that is a major security treat. Therefore Microsoft raised security restrictions and client-side printing is either not permitted or highly restricted. To achieve client-side printing where all the pages of any document can be printed to the client, some kind of client-side code needs to be executed. Adobe Acrobat and Microsoft Word achieve printing entire documents by supplying a client side control that can access the entire document and print it. This document explains how to work around these restrictions when using Crystal Reports. The solution involves shrinking the Crystal Reports web viewer to the size of the viewer print button. In this way, we satisfy the requirement of client-side code. All the user needs to do, is click the print button, select the applicable printer and print the report, without ever viewing it.
The solution uses Visual Studio 2010 and SAP Crystal Reports, developer version for Microsoft Visual Studio (2010 / 2012). The following steps will display only a print button on the web form:
1. Add the Crystal Reports viewer to a web form:
2. You should now see the viewer added to the form. In the CrystalReportViewer Tasks select a report. You can choose a new report or browse to an
existing report. Neither will be used once we are done shrinking the viewer:
3. Choose your report:
4. Set the BestFit of the viewer property to false:
5. Set the Viewer Height property to 50 px and the Width property to 40px:
6. Set the following viewer properties to False:
The viewer should now be sized down to the size of the print button:
8. View the page in your application. It should look like the following:
9. In your application, add code to load a report:
10. Run the application. Click the Print button and the following dialog will be presented:
The report will print to the user selected printer attached to their computer (client side print).