Hi,
I am a newbie to birt who needed help!
I would like to display my .rptdesign as a webpage using Birt Report Engine.
Using eclipse, I have created a new ReportEngineService java class.
Below is my codes. I have managed to resolve the compilation errors but when I run it, I do not see my .rptdesign show up as a webpage. How come??
Please advise how to open a .rptdesign to a website using Report Engine.
Thank you so much for those who helps me here. Greatly appreciate!
public class ReportEngineService {
public void startEngine() {
try {
EngineConfig config = new EngineConfig();
config.setEngineHome("C:/Temp/birt-runtime-2_5_1/ReportEngine");
config.setLogConfig("C:/tmp/logs", Level.FINE);
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.
EXTENSION_REPORT_ENGINE_FACTORY);
IReportEngine engine = factory.createReportEngine(config);
engine.changeLogLevel(Level.WARNING);
IReportRunnable design = engine.openReportDesign("C:/temp/birt-runtime-2_5_1/ReportEngine/samples/hello_world.rptdesign");
IRunAndRenderTask runtask = engine.createRunAndRenderTask(design);
HTMLRenderOption renderContext = new HTMLRenderOption();
renderContext.setBaseURL("
http://localhost/");
renderContext.setBaseImageURL("
http://localhost/myimages");
renderContext.setSupportedImageFormats("JPG;PNG;BMP;SVG");
HashMap<String, HTMLRenderOption> contextMap = new HashMap<String, HTMLRenderOption>();
contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
runtask.setAppContext( contextMap );
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFileName("C:/test/2.1/output.html");
//Set output format
options.setOutputFormat("html");
runtask.setRenderOption(options);
runtask.run();
runtask.close();
Platform.shutdown();
System.out.println("Finished");
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String args[]) {
try {
ReportEngineService birtReportEngine = new ReportEngineService();
birtReportEngine.startEngine();
} catch (Throwable t) {
t.printStackTrace();
}
}
}