简体   繁体   English

使用BIRT将pdf报告保存在数据库中

[英]Save pdf report on database using BIRT

So, I'm trying to save the pdf report in database using service methode. 因此,我正在尝试使用service methode将pdf报告保存在数据库中。 I saw that there's a way to specify the output of the generated report by calling : pdfOptions.setOutputStream(output). 我看到有一种方法可以通过调用pdfOptions.setOutputStream(output)来指定生成的报告的输出。 But how can I call my save methode this way? 但是我怎么能这样称呼我的保存方法呢?

I saw this post but i'm stack at the persist point 我看到了这篇文章,但我坚持不懈

I apreciate any advice 我很喜欢任何建议

    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);

You are streaming the output directly to the client with 您正在使用以下命令将输出直接流式传输到客户端

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

If you do this, your output gets consumed and you'll not be able to save it to the database. 如果执行此操作,则会消耗您的输出,并且您将无法将其保存到数据库。

I would use a "tee" like approach, you know, with one input stream and two output streams. 我会使用一种类似“ tee”的方法,一个输入流和两个输出流。

You could write that yourself, our you just use something like the Apache TeeOutputStream . 您可以自己编写,我们只使用Apache TeeOutputStream之类的东西。

This could look like this: 可能看起来像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM