Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi Fastreports自定义预览问题_Delphi_Report_Bmp_Fastreport - Fatal编程技术网

Delphi Fastreports自定义预览问题

Delphi Fastreports自定义预览问题,delphi,report,bmp,fastreport,Delphi,Report,Bmp,Fastreport,我在FastReports上遇到问题,它无法在包含韩文字符的页面上正确打印。它只出现在打印机HP K5300 jet上,不能使用rave进行测试,没有问题。我认为这是一个快速报告的错误。我已经将我所有的报告从rave转换成FastReports,并且没有计划搬回去 我计划将生成的页面作为图像,而不将其保存到硬盘,然后生成一个新的preport。这一次,将使用生成的图像并进行打印。我知道这个解决方案不好。在等待他们的回应时,这是暂时可行的 有人知道如何从生成的页面获取图像吗?您可以使用TFRxBM

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

我计划将生成的页面作为图像,而不将其保存到硬盘,然后生成一个新的preport。这一次,将使用生成的图像并进行打印。我知道这个解决方案不好。在等待他们的回应时,这是暂时可行的


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

您可以使用TFRxBMExport(frxExportImageUnit)组件将报告保存为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;
procedure ExportToBMP(AReport:TfrxReport;AFileName:String='';
变量
BMPExport:tfrxbmexport;
开始
BMPExport:=tfrxbmexport.Create(nil);
尝试
BMPExport.ShowProgress:=真;
如果文件名为“”,则
开始
BMPExport.ShowDialog:=False;
BMPExport.FileName:=AFileName;
BMPExport.SeparateFiles:=True;
结束;
a报告。准备报告(真实);
a出口(BMP出口);
最后
免费出口;
结束;
结束;
在本例中,导出组件为每个页面使用不同的文件名。如果将“c:\path\report.bmp”作为文件名传递,则导出组件将生成c:\path\report.1.bmp、c:\path\report.2.bmp等


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

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

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

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

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;
在生产代码中,您需要覆盖其他方法来初始化和完成打印机作业、清理等


代码基于TfrxCustomImageExport的FastReport v4.0实现,专门用于页面编号和文件命名。其他FastReport版本可能需要调整。

+1谢谢您的回复。我编辑我的问题,使之更具体。你的解决方案很好。但它不必保存在drv上。如果它能产生500页呢?伙计们,你完全改变了你问题的前提。。。只是让我的答案无效,这对你最初的问题是准确的。我必须想一想,如果我想在这里发布一个不同的答案,或者只是删除这个。。。我感到失望,因为我花了(部分或大部分)我的(宝贵的)时间来帮助你,而你却把它扔掉了!如果你问的是你不想要的东西,我认为接受我的回答(或不接受)并提出一个非常新的问题更值得尊重。对此我很抱歉。我发现我们无法直接使用图像。但首先要保存它。通过编辑你的问题,你让它更难理解。您曾经问过如何在不将报表映像保存到磁盘的情况下创建报表映像,这似乎正是Jachguate的答案。韩国人和它有什么关系?为什么你从狂野到快速报道的转变是相关的?@Rob Kennedy,是的,我在韩文字符方面有问题。打印时,纸张上只显示第一个字符。对不起,我很困惑。