Fastreports自定义预览问题

发布于 2024-10-02 09:15:04 字数 270 浏览 3 评论 0原文

我在 FastReports 上遇到问题,它无法在包含韩语字符的页面上正确打印。仅在 HP K5300 jet 打印机上出现这种情况,使用 rave 对其进行了测试,没有问题。我认为这是快速报告的一个错误。我已经将所有报告从 rave 转换为 FastReports,并且没有计划移回。

我计划将生成的页面作为图像获取,而不将其保存到硬盘驱动器,然后生成新的预报告。这次,将使用并打印生成的图像。我知道这个解决方案不好。在等待他们的答复时,这是目前可行的。

有人知道如何从生成的页面获取图像吗?

I encounter problem on FastReports, it will not print correctly on pages which contain Korean character. It hapens only on Printer HP K5300 jet, T test it using rave and having no problem. I think it a bug for fast reports. I already convert all my reports from rave to FastReports and dont have plan to moved back.

I am planning to get the generated pages as images without saving it to hard drive and then generate a new preports. this time, the generated images will be used and print. I know this solution is not good. this is worable for now While waiting for their responds.

anybody has any idea how to get the images form generated pages?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

以往的大感动 2024-10-09 09:15:04

如果您只是想避免保存大量文件,可以创建一个新的导出类,以便在文件创建后立即打印并立即将其删除。

您可以创建一个全新的导出类,从内存中打印位图(例如,使用 TPrinter 类并直接在打印机画布中绘制位图)...您将了解如何检查 TfrxBMPExport 类的源文件。

以这段未经测试的代码为例,它将指导您如何创建一个新类来保存/打印/删除:

type
  TBMPPrintExport = class(TfrxBMPExport)
  private
    FCurrentPage: Integer;
    FFileSuffix: string;
  protected
    function Start: Boolean; override;
    procedure StartPage(Page: TfrxReportPage; Index: Integer); override;
    procedure Save; override;
  end;


{ TBMPPrintExport }

procedure TBMPPrintExport.Save;
var
  SavedFileName: string;
begin
  inherited;
  if SeparateFiles then
    FFileSuffix := '.' + IntToStr(FCurrentPage)
  else
    FFileSuffix := '';
  SavedFileName := ChangeFileExt(FileName, FFileSuffix + '.bmp');
  //call your actual printing routine here.  Be sure your the control returns here when the bitmap file is not needed anymore.
  PrintBitmapFile(SavedFileName);
  try
    DeleteFile(SavedFileName);
  except
    //handle exceptions here if you want to continue if the file is not deleted 
    //or let the exception fly to stop the printing process.
    //you may want to add the file to a queue for later deletion
  end;
end;

function TBMPPrintExport.Start: Boolean;
begin
  inherited;
  FCurrentPage := 0;
end;

procedure TBMPPrintExport.StartPage(Page: TfrxReportPage; Index: Integer);
begin
  inherited;
  Inc(FCurrentPage);
end;

在生产代码中,您将需要重写其他方法来初始化和完成打印机作业、清理等。

代码基于在 FastReport v4.0 上实现了 TfrxCustomImageExport,专门用于页码和文件命名。它可能需要针对其他 FastReport 版本进行调整。

If you just want to avoid saving a lot of files, you can create a new export class to print the file just after it is created and delete it instantly.

You can create a whole new export class which print the bitmap from memory (for example, using the TPrinter class and drawing the bitmap directly in the printer canvas)... you will learn how checking the source file of the TfrxBMPExport class.

Take this untested code as an example which will guide you how to create a new class to save/print/delete:

type
  TBMPPrintExport = class(TfrxBMPExport)
  private
    FCurrentPage: Integer;
    FFileSuffix: string;
  protected
    function Start: Boolean; override;
    procedure StartPage(Page: TfrxReportPage; Index: Integer); override;
    procedure Save; override;
  end;


{ TBMPPrintExport }

procedure TBMPPrintExport.Save;
var
  SavedFileName: string;
begin
  inherited;
  if SeparateFiles then
    FFileSuffix := '.' + IntToStr(FCurrentPage)
  else
    FFileSuffix := '';
  SavedFileName := ChangeFileExt(FileName, FFileSuffix + '.bmp');
  //call your actual printing routine here.  Be sure your the control returns here when the bitmap file is not needed anymore.
  PrintBitmapFile(SavedFileName);
  try
    DeleteFile(SavedFileName);
  except
    //handle exceptions here if you want to continue if the file is not deleted 
    //or let the exception fly to stop the printing process.
    //you may want to add the file to a queue for later deletion
  end;
end;

function TBMPPrintExport.Start: Boolean;
begin
  inherited;
  FCurrentPage := 0;
end;

procedure TBMPPrintExport.StartPage(Page: TfrxReportPage; Index: Integer);
begin
  inherited;
  Inc(FCurrentPage);
end;

In production code you will want to override another methods to initialize and finalize the printer job, cleaning up, etc.

Code is based on FastReport v4.0 implementation of TfrxCustomImageExport, specially for page numbering and file naming. It may require adjustments for other FastReport versions.

以往的大感动 2024-10-09 09:15:04

您可以使用 TfrxBMPExport(frxExportImage 单元)组件将报表保存为 BMP。

例如,此代码将导出报告:

procedure ExportToBMP(AReport: TfrxReport; AFileName: String = '');
var
  BMPExport: TfrxBMPExport;

begin
  BMPExport := TfrxBMPExport.Create(nil);
  try
    BMPExport.ShowProgress := True;
    if AFileName <> '' then
    begin
      BMPExport.ShowDialog := False;
      BMPExport.FileName := AFileName;
      BMPExport.SeparateFiles := True;
    end;
    AReport.PrepareReport(True);
    AReport.Export(BMPExport);
  finally
    BMPExport.Free;
  end;
end;

在本例中,导出组件为每个页面使用不同的文件名。如果您传递“c:\path\report.bmp”作为文件名,导出组件将生成 c:\path\report.1.bmp、c:\path\report.2.bmp 等。

与往常一样,如果您愿意,可以在任何表单/数据模块上删除并手动配置该组件。

You can use the TfrxBMPExport (frxExportImage unit) component to save the report as BMP.

For example, this code will export the report:

procedure ExportToBMP(AReport: TfrxReport; AFileName: String = '');
var
  BMPExport: TfrxBMPExport;

begin
  BMPExport := TfrxBMPExport.Create(nil);
  try
    BMPExport.ShowProgress := True;
    if AFileName <> '' then
    begin
      BMPExport.ShowDialog := False;
      BMPExport.FileName := AFileName;
      BMPExport.SeparateFiles := True;
    end;
    AReport.PrepareReport(True);
    AReport.Export(BMPExport);
  finally
    BMPExport.Free;
  end;
end;

The Export component, in this case, uses a different file name for each page. If you pass 'c:\path\report.bmp' as the filename, the export component will generate c:\path\report.1.bmp, c:\path\report.2.bmp and such.

As usual, you can drop and manually configure the component on any form/data module if you prefer that way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文