Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
BIRT is generating reports without BIRT report runtime
Malintha Adikari
<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
Clement Wong
<p>You are using the Report Engine API as part of the BIRT Engine.</p>
<p> </p>
<p>For background info</p>
<ul class=""><li><strong>Report Engine API</strong> - The org.eclipse.birt.report.engine.api package hierarchy contains the API to access the report generation functions. This API provides the most commonly used functionality for a reporting application. The key class in the Report Engine API is ReportEngine. This class provides access to all the tasks required to create the desired output file from a BIRT design (.rptdesign) or a BIRT document (.rptdocument). The Report Engine API also includes the classes and packages that support the scripting capabilities of a report design.<br>
</li>
<li><strong>Design Engine API</strong> - The org.eclipse.birt.report.model.api package hierarchy is by far the larger of the two BIRT APIs. This API provides access to the content and structure of a BIRT design, a template, or a library. A BIRT based application can call this API to change the structure of a BIRT design. The Design Engine API is also used in the development of a custom BIRT designer.<br>
</li>
<li><strong>Chart Engine API</strong> - The org.eclipse.birt.chart package hierarchy contains the API that a developer of a custom chart generator uses. A BIRT based application can also use this API in conjunction with the Report Engine and Design Engine APIs to create and modify chart elements in a BIRT design.</li>
</ul><p> </p>
<p>Here is a simple execution of a report using the REAPI in Java:</p>
<p><a data-ipb='nomediaparse' href='
https://wiki.eclipse.org/Simple_Execute_(BIRT)_2.1'>https://wiki.eclipse.org/Simple_Execute_(BIRT)_2.1</a></p>
;
<p> </p>
<p>And also more in-depth documentation:</p>
<p><a data-ipb='nomediaparse' href='
http://developer.actuate.com/be/documentation/ihub3-dev/AIG/aig24/index.html#page/aig/Programming.1.07.html'>http://developer.actuate.com/be/documentation/ihub3-dev/AIG/aig24/index.html#page/aig/Programming.1.07.html</a></p>
;
Malintha Adikari
<p>Thank you very much for the explanation. I went through <a data-ipb='nomediaparse' href='
https://wiki.eclipse.org/Simple_Execute_(BIRT)_2.1'>https://wiki.eclipse.org/Simple_Execute_(BIRT)_2.1</a> and
I have one thing to get clarified. In the code you have pointed out, I could find following lines where it creates EngineConfig object and set engine home property to it</p>
<p> </p>
<p><span style="color:rgb(63,127,95);font-style:italic;">// Configure the Engine and start the Platform</span><br><strong>config <span style="color:rgb(0,0,0);">=</span> <span style="color:rgb(127,0,85);font-weight:bold;">new</span> EngineConfig<span style="color:rgb(0,0,0);">(</span><span style="color:rgb(0,0,0);">)</span><span style="color:rgb(0,0,0);">;</span><br>
config.<span style="color:rgb(0,0,0);">setEngineHome</span><span style="color:rgb(0,0,0);">(</span><span style="color:rgb(42,0,255);">"C:/birt-runtime-2_1_1/birt-runtime-2_1_1/ReportEngine"</span><span style="color:rgb(0,0,0);">)</span><span style="color:rgb(0,0,0);">;</span></strong></p>
<p> </p>
<p><span style="color:rgb(0,0,0);">And in the comment I says</span></p>
<p> </p>
<p><em><span style="color:rgb(51,51,51);font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;">"<span style="font-size:18px;">Also, you should have downloaded and installed the birt-runtime. (I guess you have because otherwise what did you set the engine home in the code above?</span>)"</span></em></p>
<p> </p>
<p><span style="color:rgb(51,51,51);font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;">According to my understanding installing birt-runtime is not a must to generate a report. Could you please verify whether my understanding is correct ?</span></p>
Clement Wong
<p>You need the BIRT Runtime to generate reports.</p>