大量のファイルを保存したくない場合は、新しいエクスポート クラスを作成して、ファイルを作成した直後に印刷し、すぐに削除することができます。
メモリからビットマップを印刷するまったく新しいエクスポート クラスを作成できます (たとえば、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;
プロダクション コードでは、別のメソッドをオーバーライドして、プリンター ジョブの初期化とファイナライズ、クリーンアップなどを行う必要があります。
コードは、TfrxCustomImageExport の FastReport v4.0 実装に基づいており、特にページ番号付けとファイル命名に使用されます。他の FastReport バージョンでは調整が必要になる場合があります。