Print a Remotely Created Document

This tutorial illustrates how to use the Document Preview for WPF to publish a document that is generated remotely by the WCF report service.

Create a WPF Application

To get started with this tutorial, open an existing WPF Application with a print preview, or create a new one from scratch. To learn how to add a print preview to a WPF application, refer to the Document Preview tutorial.

Prepare the Server Part

  1. To add a server-side application to the solution, right-click the solution item in the Solution Explorer. In the invoked drop-down menu, point to Add, and then select NewProject.

    Howto-WPF-End-User-Reporting-Application00

    In the invoked dialog, expand the Visual C# category, select Web, select ASP.NET Empty Web Application and click OK.

    Howto-WPF-End-User-Reporting-Application01

  2. Next, add a report service to the server-side application. To do this, right-click the WebApplication1 item in the solution explorer. In the invoked drop-down menu, point to Add, and then select New Item.

    Howto-WPF-End-User-Reporting-Application02

    In the invoked Add New Item dialog, expand the Visual C# category, select Reporting, select DevExpress v18.1 Report Service and click Add.

    Howto-WPF-End-User-Reporting-Application03

  3. In the same way, add a report to the server-side application.
  4. Provide a layout to the added report. For detailed instructions on how to create various kinds of report layouts, refer to the Create Popular Reports documentation section.

Prepare the Client Part

  1. Switch to the WPF project and handle the main window's Loaded event. In the event handler, create a RemoteDocumentSource that will be used by the Document Preview to obtain document data from the server side.
  2. To establish a connection to the server-side application, specify the following properties of the created RemoteDocumentSource.

    • ServiceUri - specifies a report service endpoint address.
    • ReportName - specifies a fully-qualified report name.

    Be sure to specify the correct port in the ServiceUri property. To check which port is used by your project, select the server-side application in the Solution Explorer, and check the URL property in the Properties window. To learn how to change the port used by your web application, refer to the following MSDN topic: How to: Specify a Port for the Development Server.

  3. Assign the remote document source to the DocumentViewerControl.DocumentSource property of the Document Viewer Control.
  4. Next, call the RemoteDocumentSource.CreateDocument method to generate the document for the print preview.

The following code sample illustrates the described steps.

using DevExpress.ReportServer.Printing;
using System.Windows;
// ...

private void Window_Loaded(object sender, RoutedEventArgs e) {
    RemoteDocumentSource documentSource = new RemoteDocumentSource() {           
        ServiceUri = "http://localhost:53206/ReportService1.svc",
        ReportName = "WebApplication1.XtraReport1, WebApplication1"
    };
    documentPreview1.DocumentSource = documentSource;
    documentSource.CreateDocument();
}

Launch the Application and View the Result

The client-side print preview is now capable of obtaining documents created on the application's server side.

To preview the document, run the application. To print or export the previewed report, use corresponding toolbar commands.

wpf-ribbon-document-preview-result

Limitations

When the Document Preview shows remotely created documents, it does not provide the following capabilities:

  • Change document page settings in the Page Setup dialog;
  • Scale the document content;
  • Display thumbnails;
  • Use editing fields;
  • Search for a specific text using the Search panel;
  • Add watermarks.