Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

loadfromrtfstream

edited April 2002 in General
Hello

i have an rtf text in a memory stream now i want to print this text
in the detail pipiline how can i do this.

When can i load the richtext with loadfromrtfstream and which components do
i have to use the db version or the other one

greetz Frank

Comments

  • edited April 2002
    You can use a TppRichText component and load the RichText data into the
    component's RichText property from the memory stream either in the OnPrint
    event of the component or any other event that is guaranteed to fire before
    the component is laid onto the page (ie. Detail Band's BeforePrint). You can
    use the LoadFromMemoryStream method of the component, ie.

    lRTFStream.position := 0;
    ppRichText1.LoadFromRTFStream(lRTFStream);

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited April 2002
    Hello it has to be printed many times in the detailband
    where should i put the code then

    grtzz Frank

  • edited April 2002
    Each RichText component has it's own RichText string reference. Therefore if
    you need multiple RichText components throughout the detailband, because of
    the way dDlphi handles string references, the best solution would be to copy
    the string into a globally accessible variable and have each of the
    components reference it. This would increase performance and save memory.
    You would want to do this in the in the BeforePrint event of the detail
    band. For example.

    procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject);
    var
    lStream: TMemoryStream;
    begin
    lStream := TMemoryStream.Create;

    ... load rich text data into stream

    lStream.Position := 0;
    SetLength(FRichText, lStream.Size); // FRichText is a global richtext
    string
    lStream.Read(PChar(FRichText)^, lStream.Size);

    ppRichText1.RichText := FRichText;
    ...
    ppRichTextX.RichText := FRichText;

    end;

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.