You can set PDF printing in your Silverlight project to allow printing 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.
If PDF printing is set up in the Silverlight project, you see a Print dialog appear on clicking the Print button in the SilverlightViewer toolbar:
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 you click the Print button.
Caution:
- If your Web browser does not support JavaScript and Adobe Reader, the Silverlight Viewer will use its default printing instead of the PDF printing. Also, PDF printing is not supported in the Silverlight Out-of-Browser applications.
- Silverlight viewer is deprecated and will be obsolete in ActiveReports 13.
- Open your Silverlight project or create a new Silverlight project as described in Using the SilverlightViewer.
- In Solution Explorer, open the Web.config file.
- Make sure that the http handlers have been added to the Web.config file. The http handlers are added to the Web config automatically when you add ActiveReports 12 Web Service - see Using the Silverlight Viewer for details:
XML code. Handlers appear in the XML view of the Web.config file inside the system.web section. |
Copy Code
|
<httpHandlers> <add verb="*" path="*.AR12" type="GrapeCity.ActiveReports.Web.Handlers.ReportBinariesStreamer, GrapeCity.ActiveReports.Web.v12, Version=12.0.xxxx.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> <add verb="*" path="*.AR12Web" type="GrapeCity.ActiveReports.Web.Handlers.WebCacheAccessHandler, GrapeCity.ActiveReports.Web.v12, Version=12.0.xxxx.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> <add verb="*" path="*.ActiveReport" type="GrapeCity.ActiveReports.Web.Handlers.CompiledReportHandler, GrapeCity.ActiveReports.Web.v12, Version=12.0.xxxx.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> <add verb="*" path="*.rpx" type="GrapeCity.ActiveReports.Web.Handlers.RpxHandler, GrapeCity.ActiveReports.Web.v12, Version=12.0.xxxx.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> <add verb="*" path="*.RDL,*.rdlx" type="GrapeCity.ActiveReports.Web.Handlers.RdlxHandler, GrapeCity.ActiveReports.Web.v12, Version=12.0.xxxx.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" /> <remove verb="*" path="*.asmx" /> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </httpHandlers>
|
Note: You might need to 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:
To write code in Visual Basic.NET
Visual Basic.NET Code. Paste to MainPage.xaml.vb to the Viewer1_Loaded event. |
Copy Code
|
Viewer1.PdfPrint = True |
To write code in C#
C# Code. Paste to MainPage.xaml.cs to the viewer1_Loaded event. |
Copy Code
|
viewer1.PdfPrint = true; |
See Also