Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

OfficeImage.DiscardCachedData() Method

In This Article

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

Namespace: DevExpress.Office.Utils

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

NuGet Package: DevExpress.Office.Core

#Declaration

public virtual void DiscardCachedData()

#Remarks

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... 
    }
    img.Image.DiscardCachedData();
}
richEditControl1.ExportToPdf(pdfStream);
See Also