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

PageInfoDataProviderBase Class

A service enabling the XRPageInfo control to display custom information (e.g., the name of a logged user instead of a user under whose account the web server is running).

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v19.1.Core.dll

Declaration

public abstract class PageInfoDataProviderBase

Remarks

In the following example, all PageInfo bricks are processed using the PageInfoDataProviderBase class. The PageInfo.UserName method returns information about the current HttpContext user.


using DevExpress.XtraPrinting;
using System.Web;
// ...

class CustomPageInfoDataProvider : PageInfoDataProviderBase {
    readonly HttpContext httpContext;
    public CustomPageInfoDataProvider(HttpContext httpContext) {
        this.httpContext = httpContext;
    }

    public override string GetText(PrintingSystemBase ps, PageInfoTextBrickBase brick) {
        if (brick.PageInfo != PageInfo.UserName) {
            return null;
        }
        if (httpContext == null)
            return "<No Information>";
        var user = httpContext.User;
        if (user == null || user.Identity == null)
            return "<Please enable Forms or Windows security>";
        var identity = user.Identity;
        return identity.IsAuthenticated
            ? identity.Name
            : "<Guest>";
    }
}

To add the custom page info data provider to a report’s Printing System, call the PrintingSystemBase.AddService method in the WebDocumentViewerOperationLogger.BuildStarting method body of a custom WebDocumentViewerOperationLogger implementation.


using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Web.WebDocumentViewer;
using System;
using System.Web;
// ...

class CustomWebDocumentViewerOperationLogger : WebDocumentViewerOperationLogger {
    public override Action BuildStarting(string reportId, XtraReport report, ReportBuildProperties buildProperties) {
        var httpContext = HttpContext.Current;
        return () => {
            report.PrintingSystem.AddService(typeof(PageInfoDataProviderBase), new CustomPageInfoDataProvider(httpContext));
        };
    }
}

To configure a report before document creation, add the custom operation logger to the DefaultWebDocumentViewerContainer at the application startup.


using DevExpress.XtraReports.Web.WebDocumentViewer;
// ...

protected void Application_Start(object sender, System.EventArgs e) {
    DefaultWebDocumentViewerContainer.Register<WebDocumentViewerOperationLogger, CustomWebDocumentViewerOperationLogger>();
}

To download the complete example, see Web Document Viewer - How to make the XRPageInfo control display the name of a logged user using the PageInfo.UserName property.

Inheritance

Object
PageInfoDataProviderBase
See Also