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

OfficeImage.DiscardCachedData() Method

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

Namespace: DevExpress.Office.Utils

Assembly: DevExpress.Office.v18.2.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