XtraReport.ModifyDocument(Action<IDocumentModifier>) Method
Adds and/or removes the report’s document pages.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
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
In the delegate method, modify the report document’s page set using the following members exposed by the IDocumentModifier object that is passed as a parameter:
PageCount
Specifies the report document’s page count.GetPageIndexByID
Use a page’s ID instead of the Index property to identify the page, because the page index can change while changing the document’s page set. Call the GetPageIndexByID method to get a page’s current index by passing the page’s ID.InsertPage
Inserts the specified page at a specified position.RemovePageAt
Removes the specified page at a specified position.
Call the ModifyDocument method when the report’s document is already created. Use the AfterPrint event or call the 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 CreateDocument() method beforehand.
using DevExpress.XtraPrinting.Caching;
using DevExpress.XtraReports.UI;
// Create the first report and generate its document.
XtraReport1 report1 = new XtraReport1();
report1.CreateDocument();
// Create the second report and generate its document.
XtraReport2 report2 = new XtraReport2();
report2.CreateDocument();
// Add all pages of the second report to the end of the first report.
report1.ModifyDocument(x => {
x.AddPages(report2.Pages);
});
// Preview the report1 instance that has the merged document stored in memory.
Tip
Use the CachedReportSource/CachedReportSourceWeb component’s CreateDocument method to merge reports that include a large amount of data.