Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » PDFRender - OutputStream not closed ?
PDFRender - OutputStream not closed ? [message #1018881] Thu, 14 March 2013 16:03 Go to next message
Dumont Jonathan is currently offline Dumont JonathanFriend
Messages: 33
Registered: January 2013
Location: Laval
Member
Hi,

In an Eclipse RCP application, I have a report which is generated by default in HTML and displayed in the standard Web viewer. After that, the user can choose to export the report in PDF, XLS, etc.

To do this, the HTML rendering is separated in two tasks : a Run task and a Render task. Like this, the Run task generate a rptDocument file which can be reused for the different exports.

My problem occures with the PDF export. In fact, one time in three, the PDF file is well created but it's still locked by the JVM, thus I can't open or delete the file. If I close my application, the lock is released and I can correctly open or delete the pdf file.

Is it a Bug or do I forget to close something correctly ?

Here is the code of my export :
               
  // Open the rptDocument
  reportDocument = getReportEngine().openReportDocument(rptDocumentPath);

  // Create the render task, configured for the wanted export format
  IRenderTask renderTask = getReportEngine().createRenderTask(reportDocument);

  IRenderOption options = new RenderOption();
  options.setOutputFormat("pdf");
  options.setOutputFileName("myfile.pdf");
  renderTask.setRenderOption(options);

                
  try {
    // Launch the render task and close it 
    renderTask.render();
    renderTask.close();
                                        
    // Close the rptDocument
    reportDocument.close();
                    
    // Finally, open the target file with the right application
    Program.launch(exportFileName);
                    
  } catch (final EngineException e) {
    Syso ....
  } 


Thanks


Re: PDFRender - OutputStream not closed ? [message #1018888 is a reply to message #1018881] Thu, 14 March 2013 16:14 Go to previous messageGo to next message
Andrew Aiken is currently offline Andrew AikenFriend
Messages: 4
Registered: March 2013
Junior Member
Can you try:

options.setOption(IRenderOption.CLOSE_OUTPUTSTREAM_ON_EXIT, true);

Re: PDFRender - OutputStream not closed ? [message #1020462 is a reply to message #1018888] Mon, 18 March 2013 08:32 Go to previous messageGo to next message
Dumont Jonathan is currently offline Dumont JonathanFriend
Messages: 33
Registered: January 2013
Location: Laval
Member
I tried to add this option in my render task but I still have the problem...

Re: PDFRender - OutputStream not closed ? [message #1021165 is a reply to message #1020462] Tue, 19 March 2013 15:40 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

What version of BIRT are you using? I just tried this with 3.7.2 in a sample RCP app I have and I created the pdf in a local folder like c:/test/mypdf.pdf. It worked fine. I ran the code then was able to delete the file with no issue.

Re: PDFRender - OutputStream not closed ? [message #1021581 is a reply to message #1021165] Wed, 20 March 2013 10:49 Go to previous messageGo to next message
Dumont Jonathan is currently offline Dumont JonathanFriend
Messages: 33
Registered: January 2013
Location: Laval
Member
Yes, I use BIRT 3.7.2.

The fact is it was correctly working with a RunAndRender task, but now that we have distinct Run and Render tasks, the problem occured...


Re: PDFRender - OutputStream not closed ? [message #1022385 is a reply to message #1021581] Thu, 21 March 2013 19:23 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Jonathan,

I tried it with 3.7.2 using similar code to yours (separate run and render tasks). Are you storing the pdf on the local filesystem or in the workspace. I would like to recreate the issue.
Re: PDFRender - OutputStream not closed ? [message #1027813 is a reply to message #1022385] Wed, 27 March 2013 12:48 Go to previous messageGo to next message
Dumont Jonathan is currently offline Dumont JonathanFriend
Messages: 33
Registered: January 2013
Location: Laval
Member
Sorry for the delay,

In fact I store the pdf file outside the workspace, but the rptDocument is stored under a folder temp created in the workspace, under my project root.


Re: PDFRender - OutputStream not closed ? [message #1029753 is a reply to message #1027813] Sat, 30 March 2013 04:47 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I did a similar thing. I created a output directory under my project root named output and when I generated the rptdocument I wrote it to this directory:

task.run("output/resample/pdf.rptdocument");

I then read it like:

IReportDocument doc= engine.openReportDocument("output/resample/pdf.rptdocument");

Later I did a doc.close();
Previous Topic:Graph contains 4 marker lines, some not needed
Next Topic:How to set the zoom value when rendering in pdf?
Goto Forum:
  


Current Time: Sat Jul 13 19:26:00 GMT 2024

Powered by FUDForum. Page generated in 0.03790 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top