BIRT 4.3 creates invalid PDF [message #1328773] |
Fri, 02 May 2014 21:40 |
Steve Bliss Messages: 15 Registered: February 2011 |
Junior Member |
|
|
I'm generating a single report in a J2EE webapp, and the resulting PDF file won't open in Adobe Reader. I get this message:
"There was an error opening this document. The file is damaged and could not be repaired."
My app is running in RAD 8.5, using BIRT 4.3.2 jars, compiling to Java 1.7. The report is written with a scripted data set. The data is being passed to the report via the report parameters.
The report seems to be executing correctly. If I switch the format to postscript, the output document is good.
Here is the core of the Java code:
// report gets one record, in letterFields
InputStream designFile = this.getClass().getResourceAsStream("myreport.rptdesign");
IReportRunnable design = engine.openReportDesign(designFile);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
RenderOption options = new RenderOption();
options.setOutputFormat("pdf");
CircularByteBufferEx cbb = new CircularByteBufferEx(CircularByteBuffer.INFINITE_SIZE);
options.setOutputStream(cbb.getOutputStream());
task.setRenderOption(options);
// pull together data to pass to engine task
LetterBodyData lbd = new LetterBodyData();
lbd.load(letterFields);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("LetterBody", lbd);
task.setParameterValues(parameters);
// generate the output
task.run();
task.close();
cbb.getOutputStream().close();
// save the document
FileOutputStream fos = new FileOutputStream("c:\temp\myreport.pdf");
fos.write(cbb.getBuffer(), 0, cbb.getSize());
fos.close();
Any suggestions would be appreciated!
|
|
|
|
Powered by
FUDForum. Page generated in 0.02823 seconds