Skip to main content
.NET Framework 4.5.2+

OfficeImage.DiscardCachedData() Method

Closes the current image stream and releases any resources associated with the current stream.

Namespace: DevExpress.Office.Utils

Assembly: DevExpress.Office.v22.2.Core.dll

NuGet Package: DevExpress.Office.Core


public virtual void DiscardCachedData()


Call the DiscardCachedData method before exporting a custom painted image to a PDF file to preserve your modifications. This method clears the current image stream containing no information about the modified image and creates a new one that is aware of the modifications performed. The example below demonstrates this approach:

Document doc = richEditControl1.Document;
ReadOnlyDocumentImageCollection images = doc.Images.Get(doc.Range);
foreach (var img in images) {
using (Graphics gr = Graphics.FromImage(img.Image.NativeImage)) {
        // Perform custom painting... 
See Also