2017-10-23 5 views
0

最初にJasperPrintオブジェクトを作成するのではなく、結果を直接PDFファイルにストリーミングできますか?マイJasperPrintオブジェクトには、まず、あなたがディスクにJasperPrintオブジェクトを作成し...まあ、私は一種の解決策を見つけた...ストリームJasperPrint to PDF直接

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, reportparameter.getAll(), dataSource); 
// dead end 
OutputStream output = new FileOutputStream(new File("C:/Users/bla/Desktop/test/JasperReport.pdf")); 
JasperExportManager.exportReportToPdfStream(jasperPrint, output); 

答えて

0

を発生本当に大きいとjava.lang.OutOfMemoryErrorを取得することができ、その後、あなたはコンテンツをストリーミングすることができますし、ストリーム経由でPDFを作成します。 メモリの問題はもう発生しませんが、結果をディスクに保存する必要があります。

OutputStream printOut = new FileOutputStream(new File("C:/Users/bla/Desktop/test/jasperprint.jasperprint")); 
    JasperFillManager.fillReportToStream(jasperReport, printOut, reportparameter.getAll(), dataSource); 
    printOut.close(); 

    OutputStream output = new FileOutputStream(new File("C:/Users/bla/test/JasperReport.pdf")); 
    JasperExportManager.exportReportToPdfStream(new FileInputStream(new File("C:/Users/bla/Desktop/test/jasperprint.jasperprint")), output); 
    output.close(); 
+1

また、レポート仮想化ツールhttp://jasperreports.sourceforge.net/sample.reference/virtualizer/index.htmlも参照してください。 – dada67