Assign RTF String to TfrxRichView
Fast Report GURUS,
I have several DB fields, which when combined together create a valid RTF format. The resulting string then must be bound to a given TfrxRichView.
The following is my code. Please advise as to what is wrong. The code runs with no errors, but is invalid. Is their a simpler way?
procedure rtfStep07_34OnBeforePrint(Sender: TfrxComponent);
var
lStream : TMemoryStream;
lStr : string;
begin
rtfStep07_34.RichEdit.Lines.Clear;
rtfStep07_34.RichEdit.PlainText := False;
lStr := <GRP_APP_STEP_07."APPID_34_NOTE_RTF">
+ <GRP_APP_STEP_07."APPID_34_NOTE2_RTF2">
+ <GRP_APP_STEP_07."APPID_34_NOTE3_RTF3">;
lStream := TMemoryStream.Create;
try
// Saving string to the stream
lStream.Write(lStr, Length(lStr));
lStream.Position := 0;
rtfStep07_34.RichEdit.Lines.LoadFromStream( lStream );
finally
lStream.Free;
end;
end;
I have several DB fields, which when combined together create a valid RTF format. The resulting string then must be bound to a given TfrxRichView.
The following is my code. Please advise as to what is wrong. The code runs with no errors, but is invalid. Is their a simpler way?
procedure rtfStep07_34OnBeforePrint(Sender: TfrxComponent);
var
lStream : TMemoryStream;
lStr : string;
begin
rtfStep07_34.RichEdit.Lines.Clear;
rtfStep07_34.RichEdit.PlainText := False;
lStr := <GRP_APP_STEP_07."APPID_34_NOTE_RTF">
+ <GRP_APP_STEP_07."APPID_34_NOTE2_RTF2">
+ <GRP_APP_STEP_07."APPID_34_NOTE3_RTF3">;
lStream := TMemoryStream.Create;
try
// Saving string to the stream
lStream.Write(lStr, Length(lStr));
lStream.Position := 0;
rtfStep07_34.RichEdit.Lines.LoadFromStream( lStream );
finally
lStream.Free;
end;
end;
Comments
In what way is it invalid?
I do something similar with a stream in Delphi XE (not FastScript) for the standard Delphi Richtext component, and found I had to do the following:
- Ensure there was no leading whitespace before the { which opens the RTF, this was an import issue
- Convert the string to ANSI 8-bit (not the usual Unicode string)
- I used ms.WriteBuffer to send the string contents to the stream, maybe there's no other way to send 8-bit characters
- I had to toggle the wordwrap flag to get the text to wrap after loading
The RTF is fetched from an SQLite database using a local shim.