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

CachedReportSourceBase.ModifyDocument(Action<IDocumentModifier>) Method

Adds and/or removes the generated document’s pages.

Namespace: DevExpress.XtraPrinting.Caching

Assembly: DevExpress.Printing.v18.2.Core.dll

Declaration

public void ModifyDocument(
    Action<IDocumentModifier> callback
)

Parameters

Name Type Description
callback Action<IDocumentModifier>

A delegate method that allows you to modify the report document using the IDocumentModifier object passed as a parameter.

Remarks

Call the ModifyDocument method when the report’s document is already created. Use the CachedReportSourceBase.CreateDocument method beforehand.

If you use the ModifyDocument method to extend a report document with pages from another document, create the other document using the XtraReport.CreateDocument/CachedReportSourceBase.CreateDocument method beforehand.

In the delegate method, modify the document’s page set using members exposed by the IDocumentModifier object that is passed as a parameter.

The following code demonstrates how to add a report’s title page to the beginning of another report.


using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Caching;
// ... 
private void CombineTwoReports() {
    var mainReportStorage = new MemoryDocumentStorage();
    var mainReport = new XtraReport1();
    var cachedMainReportSource = new CachedReportSource(mainReport, mainReportStorage);
    cachedMainReportSource.CreateDocument();

    var titleReportStorage = new MemoryDocumentStorage();
    var titleReport= new XtraReport2();
    var cachedTitleReportSource = new CachedReportSource(titleReport, titleReportStorage);
    cachedTitleReportSource.CreateDocument();

    cachedMainReportSource.ModifyDocument(x => {
        x.InsertPage(0, cachedTitleReportSource.PrintingSystem.Pages[0]);
    }
} 
See Also