9 Answers, 1 is accepted
Currently you can't print the report directly in Silverlight without the report viewer. As a workaround our suggestion is to export the report directly in PDF as elaborated in Exporting Report in Silverlight help article. Once you have the PDF exported you can use Adobe Reader to print the report. Another approach is to hide the Silverlight Report Viewer by setting it's height and width property to 0px, set UseNativePrinting="False". Then you can print the report without showing the reportviewer with the following code:
Copy Codeprivate void PrintButton1_Click(object sender, RoutedEventArgs e)
{
var reportViewerModel = ReportViewer1.DataContext as ReportViewerModel;
if(reportViewerModel.State.Equals("ViewerPageState"))
reportViewerModel.PrintReportCommand.Execute(null);
}
Greetings,
Steve
the Telerik team

Thanks for the reply Steve.
Unfortunately, with UseNativePrinting set to False I get the following message "Printing through the Telerik ReportViewer requires web browser". Our application will run prodominantly Out of Browser :(
With UseNativePrinting set to True a print confirmation dialog appears ("Document ready. Continue with Print?").
So at this stage we'll just have to always show the report before the user selects to print - not ideal for use, but hopefully Telerik can include this as a future feature.
Thanks again,
Grant.
Unfortunately this behavior of the native Silverlight print cannot be changed. In fact we do not show the "Document ready. Continue with Print?" dialog out of courtesy, but because Silverlight requires that the print is user initiated and there is even a time frame within which you have to initiate it, otherwise an exception is thrown. You can try printing on your own through the Silverlight API to see this behavior.
Greetings,
Steve
the Telerik team

Hi Steve,
I tried your second suggestion (to hide the reportviewer) but with UseNativePrinting set to True. I'm okay with the "extra" dialog that appears by using Silverlight printing. But I have a problem if I try to print a second time, because then reportViewerModel.State is equal "PrintNoPrintState" and the printcommand won't be executed because of the if clause. By having UseNativePrinting="False" the reportViewerModel's state is always equal to "ViewerPageState" regardless how many times I print.
Any suggestions?
Tomas
The provided code snippet is meant to work only with the true PDF print and not with the Silverlight native print. If you want to use it, you can remove the reportViewerModel.State check, which should not cause a problem with the true Print.
Greetings,
Steve
the Telerik team

In simiar way i want to Export the data of a reportviewer please suggest .
thanks,
Vijetha.k

I'm using Telerik Report Silverlight Viewer 2014 Q1 and code above doesn't work because ReportViewer1.DataContext is null.
I have fully working WCF service and I'm able to print/export report from viewer but unable to invoke print command from separate button. Any idea?
Greetings,
Witold.
Try getting the ReportViewer from the visual tree as follows:
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
var layoutRoot = (FrameworkElement)System.Windows.Media.VisualTreeHelper.GetChild(
this
.ReportViewer1, 0);
var reportViewerModel = (ReportViewerModel)(layoutRoot.DataContext);
if
(reportViewerModel.State.Equals(
"ViewerPageState"
))
reportViewerModel.PrintReportCommand.Execute(
null
);
}
I hope this helps you.
Regards,
Stef
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

this is the solution, thank you.
Greetings,
Witold