Rave - Imprimindo memos |
Top Previous Next |
Tip #23 - Printing Memos from a database using TMemoBuf
Category Code Based - General
Question
How do you print Memos from a database using TMemoBuf?
Solution
The following example prints the "Notes" memo field of the current record from Table1. This is accomplished by using TMemoBuf and is quite easily done.
Delphi Example:
uses RPMemo;
procedure TForm1.ReportSystem1Print(Sender: TObject);
var MemoBuf: TMemoBuf; Stream: TMemoryStream;
begin with Sender as TBaseReport do begin MemoBuf := TMemoBuf.Create; Stream := TMemoryStream.Create; try TBlobField(Table1.FieldByName('Notes')).SaveToStream(Stream); Stream.Position := 0; MemoBuf.LoadFromStream(Stream, Stream.Size); MemoBuf.PrintStart := 1.0; // Set memo left margin position MemoBuf.PrintEnd := 4.0; // Set memo right margin position PrintMemo(MemoBuf, 0, false); finally MemoBuf.Free; Stream.Free; end; { tryf } end; { with } end;
|