Page 1 of 1

Incorrect load RTF from db

Posted: Wed Apr 29, 2015 8:52 am
by tobi
Hi,
I'm a new user and I have problem with loading RTF from the database:

for example before saving I have:
1. aaaaa

but after the loading I have:
aaaaa

also this bolded text is in a different color than it should be.

On my form I have:
//save to db
var
oStream : TStringStream;
sText : string;
begin
oStream := TStringStream.Create('');
try
if RichViewEdit.SaveRTFToStream(oStream, False) then begin
oStream.Seek(0, soFromBeginning);
sText := oStream.ReadString(oStream.Size);
sql.FieldByName('rtftext').AsString := sText;
end;
finally
oStream.Free;
end;
end;

// load from db:
RichViewEdit.Clear;
if not sql.FieldByName('rtftext').IsNull then begin
oStream := TStringStream.Create(sql.FieldByName('rtftext').AsString);
try
oStream.Position := 0;
RichViewEdit.LoadRTFFromStream(oStream);
RichViewEdit.Format;
finally
FreeAndNil(oStream);
end;
end;

What i'm doing wrong? Have you got any ideas?

Thank you in advance

Posted: Wed Apr 29, 2015 12:43 pm
by tobi
I found the solution:

RichViewEdit.RTFReadProperties.TextStyleMode := rvrsAddIfNeeded;
RichViewEdit.RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded;
RichViewEdit.RVFOptions := RichViewEdit.RVFOptions+[rvfoSaveTextStyles, rvfoSaveParaStyles];