WPCubed Product Support

Load from file HTML and save to rtf file and load rtf file -> Image broken

wpsupport

This code simply clears the file names for the linked images.

procedure TForm1.WPRichText1PrepareImageforSaving(
 RTFData: TWPRTFDataCollectionBase; Writer: TWPCustomTextWriter;
 TextObject: TWPTextObj; var DontSave: Boolean);
begin
 if TextObject.IsImage then
 begin
     TextObject.ObjRef.StreamName := '';
     TextObject.ObjRef.FileName := '';
 end;
end;

Alternatively you can save using this flag:

WPRichText1.SaveToFile( SaveDialog1.FileName, false, 'AUTO-AlwaysEmbed');

#4 ♥ 0
1.2k Views 6 links 2 users read 2 min

Yes, they are linked but are no longer displayed correctly. We have big red crosses instead. And I don't want to save the image outside the text content. I want the images to be embedded.

When using your test application, if I save the default document in RTF format, this is what we get for an image:
🖼 f.php?h=0bvDeUWF&p=1 (www.cdip.com)

🖼 f.php?h=28IkaKAQ&p=1 (www.cdip.com)

When you save this content in HTML, you get this:
🖼 f.php?h=1OZadll2&p=1 (www.cdip.com)

And if we load this HTML file, we get this: (We note that the layout of certain elements has changed.)

🖼 f.php?h=0KiYt8oN&p=1 (www.cdip.com)

then save it as RTF, we get this: (We can see that the image is still in base64 format.)
🖼 f.php?h=2iC26a7l&p=1 (www.cdip.com)

But if we load this new rtf file, we get this:
🖼 f.php?h=1du99MCK&p=1 (www.cdip.com)

We can see that the image is no longer displayed correctly.

I don't see what I'm supposed to do with the OnPrepareImageForSaving event to make it display correctly, while still having the image embedded in the document content.

#3 ✎ ♥ 0
wpsupport

HTML usually uses linked images. They are also added as linked images to RTF.

If you do not want this you can use the OnPrepaerImageForSaving event to manipulate the image object.

Of course it depends a lot on the HTML code

#2 ♥ 0

Hello,

There is a problem when loading an HTML file and converting it to RTF—the image information is lost.

Open the test application.

Add a text and an image and save it in .html format.

Load this file in .html format.

Save this content in rtf format.

Load this file in .rtf format => the image is broken.

I have version WPTools 9.4.2.0.

Please let me know if there is anything I can do to avoid this problem and/or if it will be fixed in a future version.

#1 ✎ ♥ 0