WebDocumentViewerOperationLogger Class
A service enabling you to log events related to processing reports and generated documents by the Web Document Viewer engine.
Namespace: DevExpress.XtraReports.Web.WebDocumentViewer
Assembly: DevExpress.XtraReports.v19.2.Web.dll
NuGet Package: DevExpress.Web.Reporting.Common
Declaration
Remarks
The following example illustrates how to use the WebDocumentViewerOperationLogger to restrict exporting a report to any format except PDF. Although the export options available to end-users may be also customized on the client, the server-side approach illustrated below is preferred in some scenarios.
using DevExpress.XtraReports.Web.WebDocumentViewer;
using DevExpress.XtraPrinting;
using System;
// ...
public class MyOperationLogger : WebDocumentViewerOperationLogger {
public override void ExportDocument(string documentId, string format, ExportOptions options, PrintingSystemBase printingSystem) {
if (format != "pdf") {
throw new NotSupportedException(String.Format("Export to {0} format is not allowed!", format.ToUpper()));
}
// Specify the default PDF export options.
options.Pdf.Assign(new PdfExportOptions());
base.ExportDocument(documentId, format, options, printingSystem);
}
}
Register a custom operation logger service at the application startup as shown in the following code snippets:
using DevExpress.XtraReports.Web.WebDocumentViewer;
// ...
protected void Application_Start(object sender, System.EventArgs e) {
// ...
DefaultWebDocumentViewerContainer.RegisterSingleton<WebDocumentViewerOperationLogger, MyOperationLogger>();
}
Tip
To build report documents synchronously (e.g., to access HttpContext values in the XRControl.BeforePrint event handlers of a report), use the WebDocumentViewerOperationLogger.BuildStarting method.
Examples
For more information on services, refer to the following help topics:
- Register Services in the Document Viewer (ASP.NET Web Forms)
- Register Services in the Document Viewer (ASP.NET MVC)
- Register Services in the Document Viewer (ASP.NET Core)