.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

OfficeImage.DiscardCachedData() Method

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

Namespace: DevExpress.Office.Utils

Assembly: DevExpress.Office.v21.1.Core.dll

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