Page 1 of 1

How can I print ScaleRichView from Fastreport?

Posted: Mon Mar 17, 2014 9:55 am
by starhu
Hello,

I have RichView data in a blob field.

I need to load it into a TFrxRichView component of FastReport.

How can I do it? All I can see now is unreadable characters. I suppose I need to convert the blob data to RichView format...

Thank you

Posted: Mon Mar 17, 2014 10:31 am
by Sergey Tkachenko
Sorry, we still did not implement support for FR.

There is an unofficial version: http://code.google.com/p/theunknownones/
But we did not test it.

My progress

Posted: Fri Jun 06, 2014 4:07 pm
by MikeP
I'm amazed a simple example hasn't been directly provided.

I did it years ago by simply rendering it to a picture and including the picture in the report. that was too limited since we were then restricted to just one page. amazingly, it was enough for quite a while.

I've been making a linkage between the two that is more full-featured.

The code below has RV generate a metafile for each page. it considers that the first page may be of a different size than later pages and also that the last page may not be the full height.

after this, you need to bring them into FR.

Code: Select all

procedure TForm1.MakePix;

  function _MaxPageHeight(iPage:integer):integer;
  begin
    if iPage=1 then
      Result:=300   // this value will be from FR's Engine.FreeSpace value
      else
      Result:=500;   // just a test value
  end;

const
  icWidth=300;   // just a test value
var
  iPage:integer;
  bmp:TBitmap;
  rh:TRVReportHelper;
  Metafile : TMetafile;
  MCanvas : TMetafileCanvas;
begin
  rh:=TRVReportHelper.Create(self);
  rh.RichView.Style:=RVStyle1;
  rh.RichView.LoadRVF('doc.rvf');
  bmp:=TBitmap.Create;
  bmp:=TBitmap.Create;
  rh.Init(bmp.Canvas, icWidth);
  bmp.Free;
  iPage:=1;

  while rh.FormatNextPage(_MaxPageHeight(iPage)) do
    begin
      Metafile := TMetafile.Create;
      Metafile.Width  := icWidth;
      Metafile.Height := _MaxPageHeight(iPage);

      // GetLastPageHeight only NZ on last page
      if rh.GetLastPageHeight>0 then
        Metafile.Height:=rh.GetLastPageHeight;

      MCanvas := TMetafileCanvas.Create(Metafile, 0);
      MCanvas.Font.PixelsPerInch := PixelsPerInch;
      rh.DrawPage(iPage, MCanvas, False, Metafile.Height);
      MCanvas.Free;

      MetaFile.SaveToFile('c:\tmp\' + inttostr(iPage) + '.wmf');

      inc(iPage);
    end;
end;