Skip to main content



      Home
Home » Archived » BIRT » Open report after created
Open report after created [message #90947] Tue, 15 November 2005 04:24 Go to next message
Eclipse UserFriend
Hi all,
when I create a pdf report from my standalone application and I try to
open it without close application, I obtain an access violation error.
When I open report after I have closed my standalone application, the
message doesn't appare.
I have created the report with the code on the BIRt web site and after I
have destroyed engine with engine.destroy() method; I have put
engine.destroy in finally block but nothing is occurred.

I have need for your help.
Thanks,
Pietro

Here is my code:

EngineConfig config = new EngineConfig( );
config.setEngineHome(System.getProperty("BIRT_HOME")+"/Report Engine");
HTMLEmitterConfig hc = new HTMLEmitterConfig();
HTMLCompleteImageHandler imageHandler = new
HTMLCompleteImageHandler( );
hc.setImageHandler( imageHandler );
config.setEmitterConfiguration(
HTMLRenderOption.OUTPUT_FORMAT_PDF, hc );

ReportEngine engine = new ReportEngine(config);
String name = "data/fattura.rptdesign";
String format = "pdf";
IReportRunnable report = null;
try {
report = engine.openReportDesign(name);
}
catch (EngineException e){
System.err.println( "Report " + name + " not found!\n" );
engine.destroy( );
return;
}
IRunAndRenderTask task = engine.createRunAndRenderTask(report);
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat(format);
String output = name.replaceFirst(".rptdesign", "." + format);
options.setOutputFileName(output);
task.setRenderOption(options);
try{
task.run();
System.out.println( "Created Report " + output + ".\n");
}
catch( EngineException e1 ){
System.err.println("Report " + name + " run failed.\n");
System.err.println(e1.toString());
}
finally{
engine.destroy();
}
Re: Open report after created [message #91020 is a reply to message #90947] Tue, 15 November 2005 07:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mlorenz.nc.rr.com

I'll post what I do to open the resulting report. Be aware that this only
works for HTML output. For PDF, I get the same error you do. I've tried
everything...I have previously posted to ask if anyone knows how to force
BIRT to close the output file, but no one answered. Anyway, I hope this
helps somewhat. BTW, I am on 1.0.1 - don't know if 2.0 has fixed this.

The code tries to open the resulting file and outputs an error message to
the console if it fails. It has some capabilities that you could simplify
if you like (e.g. it allows for blanks in a report name and filename).
The code starts after engine.destroy()

============== code ===============
//open the output file
String filePath = "\"C:/BIRT/";
filePath += resultsReport.getOutputFilename() + "\"";
try {
String[] cmd = new String[3];
cmd[0] = "cmd.exe";
cmd[1] = "/C";
cmd[2] = filePath;
System.out.println(cmd[2]);
Process p = Runtime.getRuntime().exec(cmd);
int exitVal = p.waitFor();
System.out.println("Exit code = " + exitVal);
String line = null;
StringBuffer output = new StringBuffer();
BufferedReader procout = new BufferedReader(new
InputStreamReader(p.getInputStream()));
while ((line = procout.readLine()) != null)
{
output.append(line + " ");
}
BufferedReader procerror = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
while ((line = procerror.readLine()) != null)
{
output.append(line + " ");
}
System.out.println(output.toString());
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
Re: Open report after created [message #91035 is a reply to message #91020] Tue, 15 November 2005 08:57 Go to previous message
Eclipse UserFriend
Originally posted by: bristow.startrekitalia.com

Thanks Mark,
but I have generated a pdf report. I'd like find a solution for open pdf
report after generated. I have BIRT 1.0.1.

Pietro
Previous Topic:How to get the chart examples to run
Next Topic:Help with error: The selected file does not have any columns in it
Goto Forum:
  


Current Time: Tue Jul 22 07:44:05 EDT 2025

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

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

Back to the top