xtrareports-17015-desktop-reporting-common-features-printing-print-reports-in-wpf-print-a-remotely-created-document.md
This tutorial illustrates how to use the Document Preview for WPF to publish a document that is generated remotely by the WCF report service.
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.
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.
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.
In the same way, add a report to the server-side application.
Design a layout for the added report. For instructions on how to create different report layouts, refer to the Create Reports documentation section.
Switch to the WPF project and handle the main window’s Loaded event. In the event handler, create a RemoteDocumentSource that the Document Preview uses to obtain document data from the server.
To establish a connection to the server-side application, specify the following properties of the created RemoteDocumentSource.
Assign the remote document source to the DocumentViewerControl.DocumentSource property of the Document Viewer Control.
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();
}
Imports DevExpress.ReportServer.Printing
Imports System.Windows
' ...
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim documentSource As New RemoteDocumentSource() With {.ServiceUri = "http://localhost:53206/ReportService1.svc", .ReportName = "WebApplication1.XtraReport1, WebApplication1"}
documentPreview1.DocumentSource = documentSource
documentSource.CreateDocument()
End Sub
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.
When the Document Preview shows remotely created documents, it does not provide the following capabilities: