uses CRVData;
procedure TForm1.RichViewEdit1SaveItemToFile(Sender: TCustomRichView;
const Path: String; RVData: TCustomRVData; ItemNo: Integer;
SaveFormat: TRVSaveFormat; Unicode: Boolean; var OutStr: String;
var DoDefault: Boolean);
var StyleNo: Integer;
begin
if (SaveFormat=rvsfHTML) then begin
StyleNo := RVData.GetItemStyle(ItemNo);
if (StyleNo=rvsPicture) or (StyleNo=rvsHotPicture) or
(StyleNo=rvsBullet) or (StyleNo=rvsHotspot) then begin
OutStr := '';
DoDefault := False;
end;
end;
end;
After this change, the main picture item types will not be saved in HTML. To prevent saving other pictures (for example, table background picture), process also SaveImage2 event:
procedure TForm1.RichViewEdit1SaveImage2(Sender: TCustomRichView;
Graphic: TGraphic; SaveFormat: TRVSaveFormat; const Path,
ImagePrefix: String; var ImageSaveNo: Integer; var Location: String;
var DoDefault: Boolean);
begin
if SaveFormat=rvsfHTML then begin
Location := '';
DoDefault := False;
end;
end;
The simplest way to do it is to store image location in rvespImageFileName item property. If you include rvsoUseItemImageFileNames in Options parameter of SaveHTML/SaveHTMLEx, value of this property will be written in <img src>.
How to set this property?
When generating documents, use SetItemExtraStrProperty.
When editing, use SetCurrentItemExtraStrProperty.
When reading RTF, set RichView.RTFReadProperties.StoreImagesFileNames = True (of course, it affects only external images, not images embedded in RTF).
RvHtmlImporter always assigns this property for imported images.
In RichViewActions, TrvActionInsertPicture assigns this property for inserted images if rvActionInsertPicture.StoreFileName=True (starting from RichViewActions v1.53)