【问题标题】:Save pdf report on database using BIRT使用 BIRT 将 pdf 报告保存在数据库中
【发布时间】:2017-05-03 10:38:37
【问题描述】:

所以,我正在尝试使用服务方法将 pdf 报告保存在数据库中。我看到有一种方法可以通过调用来指定生成报告的输出:pdfOptions.setOutputStream(output)。但是我怎么能这样调用我的保存方法呢?

我看到了这个post,但我在坚持点上堆栈

感谢任何建议

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

【问题讨论】:

    标签: java hibernate reporting birt


    【解决方案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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多