You can provide PDF printing in your Silverlight project, which allows to print a document from Silverlight to the PDF format directly. This is a good alternative to the default Silverlight printing with its large print spool size issue.
|Note: The PDF printing only works for reports that are loaded from a static RDF file (except RDF files saved on the client side) and an RPX handler. As for reports loaded from a document stream (aspx page) and WCF service, the PDFPrint property is ignored.|
If PDF printing was set up in the Silverlight project, you will see this Print dialog by clicking Print in the Silverlight Viewer toolbar:
|Note: When you print to PDF, the exceptions that occur at printing cannot be caught. Thus, if there is a printing exception, no Print dialog appears after clicking Print in the Silverlight Viewer toolbar.|
Note: PDF printing is not supported in the Silverlight Out-of-Browser applications.
Set up PDF printing in the Silverlight Viewer project
- Open your Silverlight project or create a new Silverlight project as described in Silverlight Viewer (Pro Edition).
- In Solution Explorer, open the Web.config file.
- Add the following code to the Web.config file:
XML code. Paste in the XML view of the Web.config file inside the system.web section. Copy Code
<httpHandlers> <add verb="*" path="*.rpx" type="DataDynamics.ActiveReports.Web.Handlers.RpxHandler, ActiveReports.Web, Version=6.2.3118.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> <add verb="*" path="*.ActiveReport" type="DataDynamics.ActiveReports.Web.Handlers.CompiledReportHandler, ActiveReports.Web, Version=6.2.3118.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
<add verb="*" path="*.rdf.RdfItem" type="DataDynamics.ActiveReports.Web.Handlers.RdfHandler, ActiveReports.Web, Version=6.2.3118.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff"/> </httpHandlers>
Note: You should update the Version and PublicKeyToken values to reflect the current version of ActiveReports installed on your machine.
You can find the Version and PublicKeyToken values in the Global Assembly Cache (GAC), C:\WINDOWS\ASSEMBLY.
- On MainPage.xaml, go to the Properties window and then to the Events view.
- In the list of events, double-click the viewer1_Loaded event.
- On MainPage.xaml.cs/vb that opens, add the following code to the viewer1_Loaded event:
Paste to MainPage.xaml.cs to the viewer1_Loaded event
viewer1.ViewModel.PdfPrint = true;