corelibraries-devexpress-dot-xtraprinting-dot-caching-dot-cachedreportsourcebase-dot-modifydocument-x28-system-dot-action-devexpress-dot-xtrareports-dot-idocumentmodifier-x29.md
Adds and/or removes the generated document’s pages.
Namespace : DevExpress.XtraPrinting.Caching
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public void ModifyDocument(
Action<IDocumentModifier> callback
)
Public Sub ModifyDocument(
callback As Action(Of IDocumentModifier)
)
| 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.
|
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.XtraPrinting.Caching;
using DevExpress.XtraReports.UI;
// ...
// Create the first report and generate its document.
var storage1 = new MemoryDocumentStorage();
var report1 = new XtraReport1();
var cachedReportSource1 = new CachedReportSource(report1, storage1);
cachedReportSource1.CreateDocument();
// Create the second report and generate its document.
var storage2 = new MemoryDocumentStorage();
var report2 = new XtraReport2();
var cachedReportSource2 = new CachedReportSource(report2, storage2);
cachedReportSource2.CreateDocument();
// Add all pages of the second report to the end of the first report.
// Use either XtraReport.ModifyDocument() or CachedReportSource.ModifyDocument() to modify the report document.
report1.ModifyDocument(x => {
x.InsertPage(1, cachedReportSource2.PrintingSystem.Pages[0]);
});
// Use the cachedReportSource1 object to preview the first report.
Imports DevExpress.XtraPrinting.Caching
Imports DevExpress.XtraReports.UI
' ...
' Create the first report and generate its document.
Dim storage1 = New MemoryDocumentStorage()
Dim report1 = New XtraReport1()
Dim cachedReportSource1 = New CachedReportSource(report1, storage1)
cachedReportSource1.CreateDocument()
' Create the second report and generate its document.
Dim storage2 = New MemoryDocumentStorage()
Dim report2 = New XtraReport2()
Dim cachedReportSource2 = New CachedReportSource(report2, storage2)
cachedReportSource2.CreateDocument()
' Add all pages of the second report to the end of the first report.
' Use either XtraReport.ModifyDocument() or CachedReportSource.ModifyDocument() to modify the report document.
report1.ModifyDocument(Sub(x)
x.InsertPage(1, cachedReportSource2.PrintingSystem.Pages(0))
End Sub)
' Use the cachedReportSource1 object to preview the first report.
See Also