简体   繁体   中英

Save pdf report on database using BIRT

So, I'm trying to save the pdf report in database using service methode. I saw that there's a way to specify the output of the generated report by calling : 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.

You could write that yourself, our you just use something like the 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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