Skip to main content
A newer version of this page is available. .

Printing a Remotely Created Document in an ASP.NET

  • 3 minutes to read

This tutorial illustrates how to use ASPxDocumentViewer to publish a document that is generated remotely by the DevExpress Report Server or the WCF report service.

Note

This scenario is not currently supported by the HTML5 Document Viewer.

The tutorial consists of the following sections.

Create a Web Application

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

Publish a Document Generated by a WCF Report Service

The following steps are required to publish a document provided by a WCF report service.

  1. Click the ASPxDocumentViewer control’s smart tag. In the invoked actions list, click the ellipsis button for the Remote Report property.

    Asp-Preview-Remote-Documet00

  2. In the first step of the invoked wizard, select Report Service and click Next.

    asp-preview-remote-document-00

  3. In the next step, specify the URI for the report service hosted by the server-side application, as well as the name of the remote report you wish to display in the document viewer. Click Next to proceed to the next wizard step.

    asp-preview-remote-document-01

  4. Specify a name for the endpoint and click Finish to exit the wizard.

    asp-preview-remote-documet-00

Publish a Document Generated by a DevExpress Report Server

The following steps are required to publish a document provided by a DevExpress Report Server.

  1. Click the ASPxDocumentViewer control’s smart tag, and select Remote Report in the invoked actions list.

    Asp-Preview-Remote-Documet00

  2. In the first step of the invoked wizard, select Report Server and click Next.

    asp-preview-remote-document-report-server-00

  3. In the next step, specify the report server address and choose the authentication type.

    asp-preview-remote-document-report-server-01

    If you selected the Report Server Authentication option, you need to specify the user credentials as well. The credentials specified are used by the wizard to obtain the information required in later steps. To learn how to pass credentials to the Report Server at runtime, refer to the code sample at the end of this section.

    Click Next to proceed to the next wizard step.

  4. In the following step, select a report to display in the Document Viewer from the list of available reports and click Next.

    asp-preview-remote-document-report-server-02

  5. Specify a name for the newly added endpoint and click Finish to exit the wizard.

    asp-preview-remote-document-report-server-03

Report Server Authentication

To pass user credentials when connecting to a Report Server at runtime, handle the DocumentViewerRemoteSourceSettings.RequestCredentials event of the object returned by the ASPxDocumentViewer.SettingsRemoteSource property.

void SettingsRemoteSource_RequestCredentials(object sender, 
DevExpress.XtraReports.Web.DocumentViewer.WebAuthenticatorLoginEventArgs e) {
    e.Credential = new DevExpress.XtraReports.Web.DocumentViewer.WebCredential("username", "password");
    e.Handled = true;
}

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 the corresponding toolbar commands.

Asp-Preview-Remote-Documet00