Home
Developing Analytics Applications
BIRT is generating reports without BIRT report runtime
Migrateduser
<p>Hi,</p>
<p> </p>
<p>I am a newbie to BIRT and wrote a simple java class to generate pdf report from my sql db. I have installed report designer in my eclipse IDE. I haven't install any BIRT runtime on my machine. What I did was designing report from eclipse and then just execute my java class. That code generated the PDF file as expected getting data from the DB. So, should I install and run BIRT report generating runtime explicitly ? Can you explain how BIRT is working here ?</p>
<p> </p>
<p> </p>
<p>Following is the main method of the java class</p>
<p> </p>
<p>Regards,</p>
<p>Malintha</p>
<p> </p>
<p><span style="color:#000080;font-weight:bold;">public static void </span>main(String[] args) {<br><br>
EngineConfig conf = <span style="color:#000080;font-weight:bold;">null</span>;<br>
ReportEngine eng = <span style="color:#000080;font-weight:bold;">null</span>;<br>
IReportRunnable design = <span style="color:#000080;font-weight:bold;">null</span>;<br>
IRunAndRenderTask task = <span style="color:#000080;font-weight:bold;">null</span>;<br>
HTMLRenderContext renderContext = <span style="color:#000080;font-weight:bold;">null</span>;<br>
HashMap contextMap = <span style="color:#000080;font-weight:bold;">null</span>;<br>
PDFRenderOption options = <span style="color:#000080;font-weight:bold;">null</span>;<br><br>
conf = <span style="color:#000080;font-weight:bold;">new </span>EngineConfig();<br>
eng = <span style="color:#000080;font-weight:bold;">new </span>ReportEngine( conf );<br><br><span style="color:#000080;font-weight:bold;">try</span><br>
{<br>
design = eng.openReportDesign(<span style="color:#008000;font-weight:bold;">"/home/malintha/projects/Reporting/pc_test_report.rptdesign"</span>);<br>
}<br><span style="color:#000080;font-weight:bold;">catch </span>(Exception e)<br>
{<br>
e.printStackTrace();<br>
System.<span style="font-style:italic;">exit</span>(-<span style="color:#0000ff;">1</span>);<br>
}<br><br>
task = eng.createRunAndRenderTask(design);<br><br>
renderContext = <span style="color:#000080;font-weight:bold;">new </span>HTMLRenderContext();<br>
renderContext.setImageDirectory(<span style="color:#008000;font-weight:bold;">"image"</span>);<br>
contextMap = <span style="color:#000080;font-weight:bold;">new </span>HashMap();<br>
contextMap.put( EngineConstants.<span style="color:#660e7a;font-weight:bold;font-style:italic;">APPCONTEXT_HTML_RENDER_CONTEXT</span>, renderContext );<br>
task.setAppContext( contextMap );<br><br>
options = <span style="color:#000080;font-weight:bold;">new </span>PDFRenderOption();<br>
options.setOutputFileName(<span style="color:#008000;font-weight:bold;">"/home/malintha/output.pdf"</span>);<br>
options.setOutputFormat(<span style="color:#008000;font-weight:bold;">"pdf"</span>);<br>
task.setRenderOption(options);<br><br><span style="color:#000080;font-weight:bold;">try</span><br>
{<br>
task.run();<br>
}<br><span style="color:#000080;font-weight:bold;">catch </span>(Exception e)<br>
{<br>
e.printStackTrace();<br>
System.<span style="font-style:italic;">exit</span>(-<span style="color:#0000ff;">1</span>);<br>
}</p>
<p>eng.destroy();<br>
}<br>
}</p>
Find more posts tagged with
Comments
There are no comments yet