Question
“How can I use a JITPipeline to provide access to a DBRichtext component on my report?”
Solution
The following example implements the JITPipeline GetfieldAsString event to access RTF data. For this example a Delphi TRichEdit is placed on a form and used as the source of the rich text. Another solution could use an .rtf file as the source of the rich text – in which case a FileStream would be used rather than the MemoryStream that is used here.
Download: RtfViaJIT.zip
Sample Delphi code:
function TForm1.ppJITPipeline1GetFieldAsString(aFieldName: String): String;
begin
if (aFieldName = 'RichTx') then
Result := GetRichEdAsString(RichEdit1);
end;
function TForm1.GetRichEdAsString(aRichEd: TRichEdit): String;
var
lRTFStream: TMemoryStream;
begin
Result := '';
{create temp memory stream}
lRTFStream := TMemoryStream.Create;
try
{save the TRichEd's rtf data to the memory stream}
aRichEd.Lines.SaveToStream(lRTFStream);
SetLength(Result, lRTFStream.Size);
{copy the rtf stream to the buffer}
lRTFStream.Position := 0;
lRTFStream.Read(Result[1], lRTFStream.Size);
finally
{free the memory stream}
lRTFStream.Free;
end;
end;