How to exclude images from saving?

  • I don't want images (TWPTextObj with wpobjImage as TWPTextObjType) to be saved when using SaveToStream. I'm using WPTOOLS format and have tried setting WP.WriteObjectMode to wobDontSaveImages , wobRTFNoBinary and wobStandardNoBinary . But images are still being saved.

    How can I exclude images from being saved?

    Edited once, last by me_csk (July 18, 2025 at 8:28 AM).

  • I see that RTFDataCollection.WriteObjectMode and wobDontSaveImages is only considered for RTF files in WPIOWriteRTF.pas and have no effect for any other format, am I correct?

  • You can the event BeforeSaveTextObject and set the TextObject:=nil to not save some of the objects depending on certain contions.

    Code
    procedure TForm1.DoBeforeSaveTextObject ( Writer : TWPCustomTextWriter;
        var TextObject : TWPTextObj) ;
    begin
       if TextObject .IsImage then TextObject  := nil;
    end;

    in OnCreate:

    Code
    WPRichText.RTFData.BeforeSaveTextObject  := DoBeforeSaveTextObject ;