Insert different Picture object after each row print in Fast Report

3.2k Views Asked by At

I am developing an application in Firemonkey (Delphi XE5) where I am using Fast report 4 for printing data. I am using TFrxUserDataSet to keep data and to print this, I am using MasterData band in fast report.

Now, I also need to print TBitamp with each row, so here the bitmap for each record will be different.

Does any body has any idea how can I do this?

1

There are 1 best solutions below

0
On

Нou can load an external image file into a picture control in your report. I'm doing this with a script that is part of the report itself using the OnBeforePrint event as follows:

PROCEDURE Data2OnBeforePrint(Sender: TfrxComponent);
VAR
  lFN               : STRING;
  lFP               : STRING;
BEGIN
  // Use the filename as found in the Media dataset fields
  lFP := Trim(< Media."ImagePath">);    // Images folder below Image Root Path
  lFN := Trim(< Media."FileName1">);    // Actual Image File Name

  WITH Picture2 DO BEGIN

    // NB: There is no checking in this example, it may be useful to do a 
    //     couple of checks before trying to load the image, especially if 
    //     the data is user entered
    LoadFromFile(ImageRootPath + IncludeTrailingSlash(lFP) + lFN);

    // Do whatever manipulations you want to with the loaded image...
    AutoSize := False;
    Width := 1620;
    Height := 1080;
    Top := 0;
    Left := (1920 - Width) / 2;

    HightQuality := True;    // Note the typo in the property name... HighQuality?
    KeepAspectRatio := True;
    Transparent := True;
    Stretched := NOT Picture3.AutoSize;
  END;
END;

Note that I have added a few user functions like ImageRootPath IncludeTrailingSlash() to make the script easier. You could do similar to check for a valid file prior to attempting to load to avoid exceptions.

My devt environment is Delphi XE5 with FastReport FMX and it works just fine. I am in the midst of moving to XE6 and FR FMX 2, but am pretty sure this will work fine.