As the reports rendered by the "Render()" web
method do not support the toolbar provided in the "ReportViewer"
control, it makes a difficult choice for a programmer to print reports from the
application directly.
One of the method to use, the printing functionality as in
toolbar of the ReportViewer control, can be implemented by certain
customization in the application. This can be said as Direct Client printing
Technique obtained by the combination of certain HTML and JavaScript Code.
The procedure starts by adding a simple object in your HTML
at the page as shown
Firstly, add a tag named object to the HTML file under the
<body> tag.
Listing 1
<OBJECT id="RSClientPrint" codeBase=
"http://urservername/reportserver?rs:Command=Get&
rc:GetImage=9.00.3042.05rsclientprint.cab#Version=2005,090,3042,000"
classid="CLSID:FA91DF8D-53AB-455D-AB20-F2F023E498D3" VIEWASTEXT> </OBJECT>
Then write a function; in our example it is named PrintAll(),
which sets the properties of the page to be printed using this object
"RSClientPrint."
You can call this function on any event at <body onload
=PrintAll()>.
Listing 2
function PrintAll()
{
RSClientPrint.MarginLeft = 12.7;
RSClientPrint.MarginTop = 12.7;
RSClientPrint.MarginRight = 12.7;
RSClientPrint.MarginBottom = 12.7;
RSClientPrint.Culture = 1033;
RSClientPrint.UICulture = 9;
RSClientPrint.Print('http://<ur server name>/ReportServer',
'/Report Project/report1&Param1=in&Param2=497&Param3=1', 'report1')
}
This code works as in ReportViewer toolbar print button uses
the ActiveX control i.e. RSClientPrint Class, to open a print dialog box which
enables the client computer to customize the print settings and enables easy
client printing.
Besides this, a lot more is there if you dig in details of
the functionality behind this, but that requires thorough reporting knowledge
and some hands on experience in windows API dealing with System32.dll. You
should learn about extracting the basic functionality of the printing that is
avoided, so as not to create confusion as well as using the code straight
forwardly in the application.