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

CachedReportSource Class

A component that manages caching logic and acts as a mediator between a report and a Document Viewer.

Namespace: DevExpress.XtraPrinting.Caching

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

Declaration

[ToolboxBitmap(typeof(ResFinder), "Bitmaps256.CachedReportSource.bmp")]
public class CachedReportSource :
    CachedReportSourceBase,
    IReport,
    IDocumentSource,
    ILink,
    IComponent,
    IDisposable,
    IServiceProvider,
    IExtensionsProvider

Remarks

Use the CachedReportSource component to avoid memory consumption-related issues when you display, print or export large documents. This component generates a report document and caches each generated page in the specified storage. The following document storages are available:

You can also inherit from the DocumentStorage class to implement a custom document storage.

The following code demonstrates how to create a CachedReportSource instance.

using DevExpress.XtraPrinting.Caching;
//...
var storage = new MemoryDocumentStorage();
var report = new MyReport();
var cachedReportSource = new CachedReportSource(report, storage);

When you dispose of the CachedReportSource component, the storage it uses is disposed of as well. The storage content is cleared if DocumentStorage.ClearOnDispose is enabled.

Note

The disposal can take some time if it is invoked while the document is generated, because the CachedReportSourceBase.StopPageBuilding method waits until the currently generated page is ready.

Display Large Reports

To display a report in a Document Viewer, assign the CachedReportSource component to the DocumentViewer.DocumentSource (WinForms) / DocumentViewerControl.DocumentSource (WFP) property. Refer to the Quick Start (WinForms) / Quick Start (WPF) section for details.

Tip

The document created by the CachedReportSource component is regenerated each time users edit it in the Document Viewer (when they change margins, paper format, or watermark).

Merge Large Reports

When you merge a large document with another document, use the CachedReportSource component’s CachedReportSourceBase.CreateDocument method beforehand to generate the document. Then, use the XtraReport.ModifyDocument or CachedReportSourceBase.ModifyDocument method to manipulate the generated document’s page set.

Print and Export Large Reports

To print or export a large document in code without displaying it in a Document View, use the CachedReportSource component’s CachedReportSourceBase.CreateDocument method to generate the document. Then access the CachedReportSource.PrintingSystem property to utilize the document’s Printing System and its printing and exporting methods.

Use Caching in Web Reporting Applications

Use the CachedReportSource class in WinForms and WPF reporting applications. To utilize document caching in Web applications, use the CachedReportSourceWeb class.

Limitations

See Also