Page 1 of 1

Export (save) to RTF without coontrol

Posted: Thu Jul 15, 2010 9:13 am
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?

Posted: Thu Jul 15, 2010 10:23 am
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;

Posted: Thu Jul 15, 2010 10:41 am
by salexn75
Thanks!!!