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

Printing RTF File

edited August 2003 in General
Hi,

I have a RTF file with many lines (more than 5000) and I want to print it in
a TppRichText. However, when I execute
ppRichText1.LoadFromFile('Arquivo.rtf), the componenent don't format the
text and show all the RTF tags. What need I make to view/print this file
correctly??

Thanks,


Weverton

Comments

  • edited August 2003
    Hi Weverton,

    Are you able to print your richtext to a Delphi TRichEd and get a correct
    display? The TppRichText component relies on the TRichEd component to read
    RTF data. Below are a couple articles that may help.


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

    You can copy RTF data from Delphi's TRichEd 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.


    ----------------------------------------------
    Article: ReportBuilder's RichText architecture
    ----------------------------------------------


    The RichText in ReportBuilder is a wrapper around Delphi's TRichEdit which
    in turn relies on Windows. There are two versions of Windows richedit -
    RichEd32.dll is the older one and RichEd20.dll is a newer one (RichEd32 is
    being phased out). Delphi by default relies on RichEd32 - the older version.
    To use some of the more advanced features of Windows RichEdit, see the topic
    on InfoPower RichEdit Support below.

    In general Windows RichEdit supports the type of formatting that you can do
    using WordPad.



    InfoPower RichEdit Support
    ---------------------------
    InfoPower from Woll2Woll Software is a popular database add-on product for
    Delphi. InfoPower's TwwRichEdit components support the Windows RichEdit2
    format. This format allows the rich text data to contain embedded bitmaps
    and OLE objects. For more information please see http:\\www.Woll2Woll.com.

    ReportBuilder includes a component that enables the TppRichText and
    TppDBRichText controls in ReportBuilder to use the formatting capabilities
    of InfoPower's TwwRichEdit when rendering RTF data. The ppWWRichEd.pas unit
    located in the ..\RBuilder\InfoPower directory defines a TwwDBRichEdit
    descendant and then registers the class with ReportBuilder. This enables the
    TppRichText and TppDBRichText controls in ReportBuilder to use the
    formatting capabilities of TwwDBRichEidt when rendering data.


    WPTools Support
    ----------------
    WPTools is a collection of components used to edit and print formatted text.
    With its own RTF engine, WPTools offers numerous features not supported by
    the standard Windows RichEd20.dll. This control lets you use tables,
    paragraph frames, headers and footers etc. Using the optional ReportBuilder
    support units for WPTools 2.x, you can print the enhanced WPTools features
    (justified text, tables, graphics...) within your ReportBuilder reports. For
    more information please see http:\\www.wptools.de.


    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2003
    Hi Nico,

    I tested the Delphi TRichEd, setting to open the RTF File in FormShow event
    and it lost the format too. However, if I open the file when the form is
    visible (ex. in a button click), then file is displayed normaly. If you
    want, I can send the RTF file to you test.

    Thanks,

    Weverton

    PS: I have in my computer RichEd32.dll and RichEd20.dll

  • edited August 2003
    Hi Weverton,

    Please send the example to support@digital-metaphors.com and I'll take a
    look.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.