Unmatched Brace error when using rv.LoadRTFFromStream
Posted: Fri Dec 03, 2010 3:55 pm
Hello:
When I try to load the following rtf text into an TRichView using LoadRTFFromStream, I get an Unmatched Brace error..... however, the exact same string displays fine when read by a DBRichViewEdit from a CLOB field.
What is wrong with the rtf string? And why does it work from a CLOB field but not from a TRichView?
Thanks,
Dale
[/code]
When I try to load the following rtf text into an TRichView using LoadRTFFromStream, I get an Unmatched Brace error..... however, the exact same string displays fine when read by a DBRichViewEdit from a CLOB field.
What is wrong with the rtf string? And why does it work from a CLOB field but not from a TRichView?
Thanks,
Dale
Code: Select all
Text := '{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard This is some {\b bold} text.\par}';
Stream := TMemoryStream.Create;
try
rv.Clear;
rv.DeleteUnusedStyles(True, True, True);
Stream.Write(Text[1], Length(Text));
Stream.Position := 0;
if not(rv.LoadRTFFromStream(Stream)) then begin
nError := rv.RTFReadProperties.ErrorCode;
if nError = rtf_ec_OK then begin
MessageBox(0, 'OKAY', '', MB_ICONINFORMATION or MB_OK or MB_APPLMODAL);
end else begin
MessageBox(0, 'Error', '', MB_ICONINFORMATION or MB_OK or MB_APPLMODAL);
end;
end;
rv.Format;
Text := GetAllText(rv);
finally
FreeAndNil(Stream);
end;