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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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; |