サーチ…


備考

pdfでフォントを正しくレンダリングするには、 拡張機能 (classpath)を常に使用する必要があります。

IDE(統合開発環境)

JasperSoft Studio

プレビューで、緑色の矢印をクリックしてレポートを実行し、エラーがなければエクスポートメニューを有効にし、エクスポートボタン(ディスクイメージ)をクリックして「Export As Pdf」を選択します。 PDF形式でエクスポート

Javaで

エクスポートするには、レポートを入力してJasperPrintオブジェクトを取得する必要があります。

単一のJasperPrint(単一のjrxml)をファイルにエクスポートする

// 1. Create exporter instance
JRPdfExporter exporter = new JRPdfExporter();

// 2. Set exporter input document
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));

// 3. Set file path for exporter output
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/path/filename.pdf"));

// 4. Create configuration instance
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();

// 5. Associate configuration with exporter
exporter.setConfiguration(configuration);

// 6. Fill export and write to file path
exporter.exportReport();

複数のJasperPrint(複数のjrxml)を1つのファイルにエクスポートする

最初のステップだけが前のセットと異なります:

List<JasperPrint> jasperPrintList = new ArrayList<>();
jasperPrintList.add(jasperPrint1);
jasperPrintList.add(jasperPrint2);

JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));

残りの手順は同じです:

exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/path/filename.pdf"));
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
exporter.setConfiguration(configuration);
exporter.exportReport();

設定の詳細については、 SimplePdfExporterConfiguration APIを参照してください。



Modified text is an extract of the original Stack Overflow Documentation
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow