How can I print ScaleRichView from Fastreport?

General TRichView support forum. Please post your questions here
Post Reply
starhu
Posts: 49
Joined: Fri Jan 17, 2014 6:33 pm

How can I print ScaleRichView from Fastreport?

Post 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
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
MikeP
Posts: 3
Joined: Mon Sep 13, 2010 7:21 pm

My progress

Post 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;
Post Reply