Printing image in Rave Reports

4.6k views Asked by At

I have an application being developed in Delphi 2009 and Rave Reports. I would like to have an image printed in the reports. How am I going to implement this?

Any suggestion would be very much appreciated.

2

There are 2 answers

1
Ken White On

Use the Draw(X, Y: Double; Graphic: TGraphic); method of a TBaseReport descendant, unless you're drawing a bitmap. In that case, use TBaseReport.PrintBitmap(X, Y: Double; ScaleX, ScaleY: Double; Bitmap: TBitmap); or PrintBitmapRect(X1, Y1, X2, Y2: Double; Bitmap: TBitmap);

Draw() is documented in the D2009 help file in ms-help://embarcadero.rs2009/Rave/draw.htm

var   
  MyLogo: TGraphic;
begin
  MyLogo := TMetafile.Create;
  try
    MyLogo.LoadFromFile('MYLOGO.WMF');
    RvNDRWriter1.Draw(1.0,2.0,MyLogo);
  finally
    MyLogo.Free;
  end; { tryf }
end;

You can find an example of PrintBitmap in the Delphi 2009 help file, topic ms-help://embarcadero.rs2009/Rave/printbitmap.htm - there's a link on that page for PrintBitmapRect().

// Print MyBitmap in upper left corner four times its size
RvNDRWriter1.PrintBitmap( 1.0, 1.0, 2.0, 2.0, MyBitmap );
0
JonDave of the Philippines On

I have the same problem with Rave Reports, it depends on what type of image you want to preview or print. If it's a WMF you can use what Ken White's example:

var   
  MyLogo: TGraphic;
begin
  MyLogo := TMetafile.Create;
  try
    MyLogo.LoadFromFile('MYLOGO.WMF');
    RvNDRWriter1.Draw(1.0,2.0,MyLogo);
  finally
    MyLogo.Free;
  end; { tryf }
end;

but when using a BMP:

RvNDRWriter1.PrintBitmap( 1.0, 1.0, 2.0, 2.0, MyBitmap );

and when using JPEG IMAGE: you have to convert first the JPEG to BMP before using calling RvNDRWriter1.

Jpeg2bmp('temp.bmp',jpegfile);
pic1.picture.loadfromfile('temp.bmp');
pic1.Visible:=true;