2017-05-03 53 views
0

因此,我試圖使用服務方法將pdf報告保存在數據庫中。我看到有一種方法可以通過調用:pdfOptions.setOutputStream(output)來指定生成的報告的輸出。但是,我怎麼能這樣稱呼我的保存方法?使用BIRT保存pdf數據庫報告

我看到這個post但我在堅持點

我apreciate

PDFRenderOption pdfOptions = new PDFRenderOption(options); 
    pdfOptions.setOutputFormat(FORMAT_PDF); 
    pdfOptions.setOption(IPDFRenderOption.PAGE_OVERFLOW, IPDFRenderOption.OUTPUT_TO_MULTIPLE_PAGES); 
    pdfOptions.setOutputStream(response.getOutputStream());//opens report on browser 
    runAndRenderTask.setRenderOption(pdfOptions); 

回答

1

您直接流輸出到客戶端

pdfOptions.setOutputStream(response.getOutputStream());//opens report on browser 

如果有任何建議堆棧你這樣做,你的輸出會被消耗掉,你將無法將它保存到數據庫中。

我會用一個「tee」類似的方法,你知道,有一個輸入流和兩個輸出流。

你可以自己寫,我們你只是使用類似Apache TeeOutputStream的東西。

這可能是這樣的:

OutputStream blobOutputStream = ...; // for writing to the DB as BLOB. 
OutputStream teeStream = TeeOutputStream(response.getOutputStream(), blobOutputStream); 
pdfOptions.setOutputStream(teeStream);