WPCubed Product Support

Attached images are lost when converting RTF to HTML

Hi,
I upraded from WPTools 6.03.05 to 6.10 and found a problem when converting RTF to HTML. The references to images are lost. Below are examples.

I am currently using TWPRichText.AsAnsiString('HTML-WriteBaseFont'). I also tried just setting the TextSaveFormat property to 'HTML' and still does not work for 6.10

WPTools 6.03.05 (works fine)
RTF:
'{\rtf1\ansi\deff0\uc1\ansicpg1252\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset2 Wingdings;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\wpprheadfoot1\paperw12240\paperh15840\margl1880\margr1880\margt1440\margb1440\headery720\footery720\endnhere\sectdefaultcl{\\generator WPTools_6.030;}{\plain\fs22 Test\par'#$D#$A'\plain\fs22{\\wptools\wpomode0\wpoframe0{\\wppicname{cid😛ART1.6DCDBFDB.img1.JPG}}{\\wppicsource{cid😛ART1.6DCDBFDB.img1.JPG}}{\bin244 '#$11#$E#$19#0'TWPTempSaveTextObjHelper'#0'TPF0'#$18'TWPTempSaveTextObjHelper'#0#7'WidthTW'#3'''#6#8'HeightTW'#3'4'#8#$C'WriteRTFMode'#7#$C'wobAutomatic'#5'Extra'#6'pType:12;Name:"cid😛ART1.6DCDBFDB.img1.JPG";Source:[[cid😛ART1.6DCDBFDB.img1.JPG]];Width:1575;Height:2100;Wrap:0;'#6'ObjTag'#2#0#0#0'???'#0'}}\par'#$D#$A'}}'

HTML
'<html>'#$D#$A'<head></head><body>'#$D#$A'<basefont face="Arial"/><div>Test</div>'#$D#$A'<div><img src="cid😛ART1.6DCDBFDB.img1.JPG" width=105 height=140/></div>'#$D#$A'</body></html>'

WPTools 6.10
RTF
'{\rtf1\ansi\deff0\uc1\ansicpg1252\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset2 Wingdings;}{\f2\fnil\fcharset2 Symbol;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\wpprheadfoot1\paperw12240\paperh15840\margl1880\margr1880\margt1440\margb1440\headery720\footery720\endnhere\sectdefaultcl{\\generator WPTools_6.060;}{\plain\fs22 Test\par'#$D#$A'\plain\fs22{\\wptools\wpomode0\wpoframe0{\\wppicname{cid😛ART1.1430AFF0.img1.JPG}}{\\wppicsource{cid😛ART1.1430AFF0.img1.JPG}}{\bin244 '#$11#$E#$19#0'TWPTempSaveTextObjHelper'#0'TPF0'#$18'TWPTempSaveTextObjHelper'#0#7'WidthTW'#3'''#6#8'HeightTW'#3'4'#8#$C'WriteRTFMode'#7#$C'wobAutomatic'#5'Extra'#6'pType:12;Name:"cid😛ART1.1430AFF0.img1.JPG";Source:[[cid😛ART1.1430AFF0.img1.JPG]];Width:1575;Height:2100;Wrap:0;'#6'ObjTag'#2#0#0#0'???'#0'}}\par'#$D#$A'}}'

HTML
'<html>'#$D#$A'<head></head><body>'#$D#$A'<div><span style="font-family:'Arial';font-size:11.00pt;">Test</span></div>'#$D#$A'<div><span style="font-family:'Arial';font-size:11.00pt;"></span></div>'#$D#$A'</body></html>'

Please check why its dropping the <img src=" .. on the HTML.

Thanks,
Jocelyn

#1 ♥ 0
5k Views 3 users read 4 min
support

Hi,

I don't know what this RTF code comes from and how to use it. However it seems to use the TWPObject class TWPTempSaveTextObjHelper which is not a valid image.

Julian

#2 ♥ 0

I upgraded WPTools recently from 6.0.3 to 6.13.1 and today ran into what seems to be the exact same problem.

The problem is that the html writer now only saves images if they have an objref. The objref won't be assigned though by the RTF reader, unless you implement the OnRequestHTTPImage event.
This isn't very efficient though for converting RTF - HTML, because you will need to load all the images.

Took me a few hours to track this one down...

function TWPHTMLWriter.WriteObject.... if (txtobj.ObjType = wpobjImage) and (txtobj.ObjRef<>nil) then....

This used to be

function TWPHTMLWriter.WriteObject
....
 if (txtobj.ObjType = wpobjImage) then
....

( Perhaps this issue has been resolved already. I have not tried the latest version yet. )

#3 ♥ 0
support

The objref won't be assigned though by the RTF reader, unless you implement the OnRequestHTTPImage event.

It would be ok to assign an empty TWPOImageObject in OnRequestHTTPImage - if only the filepath is ok. That should not take much time sinc eth image data does not have to be loaded.

Julian

#4 ♥ 0
This category is archived. No new posts are possible.