Idea need for loading/saving/removing images in a RTF

General TRichView support forum. Please post your questions here
Post Reply
kundm
Posts: 2
Joined: Fri Jan 23, 2015 9:17 am

Idea need for loading/saving/removing images in a RTF

Post by kundm »

Hi,

we are using a RichView for editing emails. Those Emails contain a footer with different pictures.
Currently we have stored about 2 million emails. Those footers are really big in sum. Because the often contain the same pictures.
My idea is to extract the images and store them not duplicated in a separated blob database table.

My problems to solve:
1) How to find and extract the images and replace them in RTF with a placeholder.
2) When a rtf is loaded to richview, how to restore those extracted images.

Should i to an parse the RTF?
Is there a more elegant way?
Does the Richview have some helpful function?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Idea need for loading/saving/removing images in a RTF

Post by Sergey Tkachenko »

Possible solutions:

1) You can implement some kind of fields typed directly in text, for example replace text inside {}. After loading the file, you can process codes like {image1} and replace them to actual images. For example, see Mailmerge-Text4 demo

2) RTF files may contain reference to image file instead of the actual image (INCLUDEPICTURE field). When TRichView reads INCLUDEPICTURE field, it calls OnImportPicture event, where you can provide your image. If this event is not processed, TRichView tries to read this picture from file.
TRichView does not have an option to save pictures as references to files in RTF, but you can implement it using OnSaveItemToFile event.
See the demo <TRichView Dir>\TRichView\Demos\DelphiUnicode\Assorted\Graphics\SharedImages\

3) You can change saving format to RVF, exclude rvfoSavePicturesBody from RVFOptions property, and use OnRVFPictureNeeded to provide the image. An example is in the same demo.
kundm
Posts: 2
Joined: Fri Jan 23, 2015 9:17 am

Re: Idea need for loading/saving/removing images in a RTF

Post by kundm »

I will try these solutions, thank you.
Post Reply