0

我正在 Firemonkey (Delphi XE5) 中开发一个应用程序,我使用 Fast report 4 打印数据。我正在使用 TFrxUserDataSet 来保存数据并打印它,我在快速报告中使用 MasterData 带。

现在,我还需要为每一行打印 TBitamp,所以这里每条记录的位图会有所不同。

有没有人知道我该怎么做?

4

1 回答 1

1

Н您可以将外部图像文件加载到报表中的图片控件中。我正在使用作为报告本身一部分的脚本执行此操作,使用 OnBeforePrint 事件,如下所示:

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;

请注意,我添加了一些用户函数,如 ImageRootPath IncludeTrailingSlash() 以使脚本更容易。您可以在尝试加载之前执行类似的操作来检查有效文件以避免异常。

我的开发环境是带有 FastReport FMX 的 Delphi XE5,它工作得很好。我正在转向 XE6 和 FR FMX 2,但我很确定这会正常工作。

于 2014-06-27T22:47:13.760 回答