Home Devices

Print a TRichView Text

edited December 2002 in Devices
Hi,

I use an evoluted rtf format with TRichView component.
How is it possible to print this (it's not a standard rtf) ?
Can TppRichText use a not standard rtf format ?

Thanks for your interest.

Comments

  • edited December 2002
    What you can do is stream the rich text from the TRichView to a TppRichText.
    Here is how you would do it for a TRichEdit:

    ------------------------------------------------
    Tech Tip: Copy RTF data from TRichEdit to TppRichText
    ------------------------------------------------

    You can copy RTF data from Delphi's TRichEdit to ReportBuilder's TppRichText
    control by using an intermediate memory stream:



    var
    lRTFStream: TMemoryStream;

    begin

    {create temp memory stream}
    lRTFStream := TMemoryStream.Create;

    {save the TRichEd's rtf data to the memory stream}
    RichEdit1.Lines.SaveToStream(lRTFStream);

    {load the rtf stream to the TppRichText}
    lRTFStream.position := 0;
    ppRichText1.LoadFromRTFStream(lRTFStream);

    {free the memory stream}
    lRTFStream.Free;


    end;


    Note: An alternative method would be to use RichEdit1.Lines.SaveToFile and
    TppRichText.LoadFromFile.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    Ok, but it's not my question.

    I don't use the "TRichEdit" standard component but an other component
    "TRichView" which is a conponent which allows to insert some images,
    metafile, OLE link etc...

    How to print a text which contains image, etc....... ?

    Thanks






  • edited December 2002
    If you have rtf that uses other features than the TRichEdit can handle, such
    as embedded images, OLE, ...etc then you'll have to write a wrapper
    component. Search our newsgroups on TRichView. I believe one customer wrote
    one, but I could not follow up on it, as our engineer who worked with the
    customer on the issue is no longer with us.

    For an example of a basic wrapper, take a look in the Infopower directory in
    your RBuilder installation directory. This creates a class that allows you
    to register a new class which uses the Infopower rich text engine to render
    the text in RB. You can do the same for TRichView, if it is a
    TCustomRichEdit descendent. If it isn't a TCustomerRichEdit descendent then
    it may be more difficult to get working.

    You could shoot an email to the TRichView authors to see if they have any
    customers who have done this that they know of.

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    OK, thanks you very much.

  • edited December 2002
    I saw on the TRichView web page that it has a TRVReportHelper component that
    can draw documents at the specified rectangle of any Canvas, including printer's
    Canvas.

    So maybe you could use the TWPaintbox and print on it using the OnDrawPaintbox
    event.


    --
    Daniel Lemire
    Programmeur,
    Conception Design Ware Inc.
    Tél.: 819-868-8853
    Fax : 819-868-8855
This discussion has been closed.