Saving all wprichtext to string

  • I have been using:

    Fields[0].asString := WPRichText.BodyText.RTFText.asString;

    to save richtext to a database. But I now need to add headers and footers. This does not save that information. Is there a way to get teh Header, Body and Footer al from a similar call? This works well because it saves images in teh richtext as wellas the text. Will need to do the same with all regions.

    • Offizieller Beitrag

    Hi,

    Zitat

    to save richtext to a database. But I now need to add headers and footers. This does not save that information. Is there a way to get teh Header, Body and Footer al from a similar call? This works well because it saves images in teh richtext as wellas the text. Will need to do the same with all regions.

    To save all text (body and header) use

    Fields[0].asString := WPRichText.AsANSIString('RTF');

    To save the header and footer and body into seperate strings use your code but over a loop of the elements of

    WPRichText.HeaderFooter

    For example

    Code
    for i:=0 to WPRichText-HeaderFoouter.Count-1 do
    begin
       if WPRichText.HeaderFooter[i].Kind in [wpIsBody, wpIsHeader, wpIsFooter] do
      begin
          Fields[xxx].asString := WPRichText.HeaderFooter[i].RTFText.asString; 
      end;
    end;

    Regards,
    Julian