0

FastReportsで問題が発生しました。韓国語の文字が含まれているページでは正しく印刷されません。プリンターHPK5300ジェットでのみ発生します。レイブを使用してテストし、問題はありません。迅速なレポートのバグだと思います。私はすでにすべてのレポートをraveからFastReportsに変換しており、元に戻す予定はありません。

生成されたページをハードドライブに保存せずに画像として取得してから、新しいプリポートを生成することを計画しています。今回は、生成された画像を使用して印刷します。私はこの解決策が良くないことを知っています。彼らの応答を待っている間、これは今のところ心配です。

生成されたページから画像を取得する方法を知っている人はいますか?

4

2 に答える 2

1

大量のファイルを保存したくない場合は、新しいエクスポート クラスを作成して、ファイルを作成した直後に印刷し、すぐに削除することができます。

メモリからビットマップを印刷するまったく新しいエクスポート クラスを作成できます (たとえば、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 バージョンでは調整が必要になる場合があります。

于 2010-11-13T03:56:40.617 に答える
1

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 などを生成します。

通常どおり、必要に応じて任意のフォーム/データ モジュールにコンポーネントをドロップして手動で構成できます。

于 2010-11-12T02:45:24.477 に答える