Skip to main content

Printing and Exporting

  • 2 minutes to read
In This Article

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;

    dxprinting-printing-client-side

    Using this approach, it is also possible to print documents from out-of-browser applications.

  • Printing via PDF.

    dxprinting-printing-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.

pages-preparing

After the document creation has completed, you can send it to a printer.

pages-ready

#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.

silverlight-export-service-visual-studio-dxprinting

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.

Export-Buttons-DocumentPreview

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).

See Also