Printing and Exporting
- 2 minutes to read
This document explains how you can print and/or export documents using DXPrinting for Silverlight.
This document consists of the following sections.
#Printing
DXPrinting for Silverlight provides the following two approaches to printing.
The client-side printing;
Using this approach, it is also possible to print documents from out-of-browser applications.
Printing via PDF.
To print a document in code, simply call the LinkBase.Print method.
Or use the corresponding button in the Document Preview toolbar (which triggers DocumentPreviewModelBase.PrintCommand).
The following dialog is shown while document pages are being prepared.
After the document creation has completed, you can send it to a printer.
#Exporting
With DXPrinting, you can export documents to a variety of popular formats (notably PDF, HTML, MHT, RTF, TXT, CSV, XLS, XLSX and XPS).
Document exporting is performed server side, using an Export Service.
To add an Export Service to a Silverlight application, select your Web project in the Visual Studio Solution Explorer. Next, choose Project | Add New Item... in the Main menu, and in the invoked dialog, double-click DevExpress v14.2 Export Service.
This will create an ExportService1.svc file in your Web project and make all necessary changes in its web.config file. This allows for the corresponding buttons to be available in the Document Viewer, which trigger the exporting methods appropriate for each file format.
All methods that are available for exporting of links (e.g., LinkBase.ExportToPdf) are asynchronous.
For each such method, you can choose whether you close the stream after you complete exporting or leave it open (and use the corresponding overloaded method either with the closeStream parameter or without).