Export (save) to RTF without coontrol

General TRichView support forum. Please post your questions here
Post Reply
salexn75
Posts: 5
Joined: Thu Jul 15, 2010 9:07 am

Export (save) to RTF without coontrol

Post by salexn75 »

I stored RVF file in database table.
Sometimes I need to the export file in RTF format. Is it possible to do without a form with the the RichView control?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You can use TRVReportHelper component. It contains an invisible TRichView itself, but it does not require a form.

If document contains tables, RVReportHelper must be formatted before saving RTF. So you need some canvas for formatting.

Code: Select all

var
  helper: TRVReportHelper;
  Canvas: TCanvas;
  DC: HDC;
begin
  helper := TRVReportHelper.Create(nil);
  helper.RichView.Style := TRVStyle.Create(helper);
  helper.RichView.Options := helper.RichView.Options+[rvoTagsArePChars];
  helper.RichView.RVFOptions := helper.RichView.RVFOptions+[rvfoLoadDocProperties];
  helper.RichView.RTFOptions := helper.RichView.RTFOptions+[rvrtfSaveDocParameters];

  helper.RichView.LoadRVFFromStream(...);

  Canvas := TCanvas.Create;
  DC := GetDC(0);
  Canvas.Handle := DC;
  helper.Init(Canvas, 600);
  helper.RichView.SaveRTF(...);
  Canvas.Handle := 0;
  Canvas.Free;
  ReleaseDC(0, DC);

  helper.Free;
end;
salexn75
Posts: 5
Joined: Thu Jul 15, 2010 9:07 am

Post by salexn75 »

Thanks!!!
Post Reply