Using external CSS programmatically
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">Hi,</p>
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">I want to use an external css when executing the BIRT report via a Java application. I've come along with a few articles (e.g. <a data-ipb='nomediaparse' href='http://developer.actuate.com/community/forum/index.php?/files/file/510-birt-dynamically-choose-css-file/'>http://developer.actuate.com/community/forum/index.php?/files/file/510-birt-dynamically-choose-css-file/</a>) which sets the css at runtime over</p>
<pre class="_prettyXprint">
design.getDesignHandle().addCss("someCss.css");</pre>
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">but it seems that it's deprecated. I'm using BIRT 4.4.2. Any suggestions how I could set a css file at runtime?</p>
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">I want to use an external css when executing the BIRT report via a Java application. I've come along with a few articles (e.g. <a data-ipb='nomediaparse' href='http://developer.actuate.com/community/forum/index.php?/files/file/510-birt-dynamically-choose-css-file/'>http://developer.actuate.com/community/forum/index.php?/files/file/510-birt-dynamically-choose-css-file/</a>) which sets the css at runtime over</p>
<pre class="_prettyXprint">
design.getDesignHandle().addCss("someCss.css");</pre>
<p style="font-size:15px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">but it seems that it's deprecated. I'm using BIRT 4.4.2. Any suggestions how I could set a css file at runtime?</p>
0
Comments
-
<p>I've a default css which I'm using in the report and now I want to use an external css with has the same structure and elements but only different font styles. Now I've done it with</p>
<p> </p>
<div>
<pre class="_prettyXprint">
ReportDesignHandle report = (ReportDesignHandle)design.getDesignHandle();
CssStyleSheetHandle css = report.openCssStyleSheet("PathToCSS/someCss.css");
report.addCss(css);
design.setDesignHandle(report);</pre>
</div>
<div> </div>
<div>but it has no effects and shows the "default" css from the report.</div>
0 -
<p>I can not get this to work. I need to import a external style sheet, I have looked all over the net and this thread is the only thing that I can find that seems to be what I am looking for. What is the <span>design in "</span><span>(</span><span>ReportDesignHandle</span><span>)</span><span>design</span><span>.</span><span>getDesignHandle</span><span>();" and "</span><span>design</span><span>.</span><span>setDesignHandle</span><span>(</span><span>report</span><span>);"</span></p>
<p> </p>
<p><span>I mean obviously it is a designHandle. but how do I set this?</span></p>
0 -
<p>Yes I am writing a java program with the report <span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">engine and I need to be able to load</span> <span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">external CSS.</span></p>
0 -
<p>Im also using BIRT 4.2.2 like David above.</p>
0 -
<p>Without access to the full code I cannot be exactly sure the object type however, my guess would be that it is actually an IReportRunnable object created similar to the following:</p>
<pre class="_prettyXprint _lang-">
IReportRunnable design = engine.openReportDesign("Reports/TopNPercent.rptdesign");
</pre>Warning No formatter is installed for the format ipb0 -
<p>Im getting an error: The method openReportDesign(String) is undefined for the type IDesignEngine</p>
<p> </p>
<p>mean anything to you? I will keep at it.</p>
0 -
<p>Are you trying to add the CSS file at run time when executing the report with the report engine or are you trying to modify and then save the report design using the design engine?</p>
<p> </p>
<p>The method I indicated is for adding at runtime when using the report engine. Which means you need to define the engine object as an IReportEngine.</p>
<pre class="_prettyXprint _lang-js">
IReportEngine engine = factory.createReportEngine( config );
</pre>
<p>Take a look at the report engine API (REAPI) documentation for more details: <a data-ipb='nomediaparse' href='https://www.eclipse.org/birt/documentation/integrating/reapi.php'>https://www.eclipse.org/birt/documentation/integrating/reapi.php</a></p>
Warning No formatter is installed for the format ipb0 -
<p>I need to add the CSS at run time and then save it.</p>
<p> </p>
<p>Here is where I define my <span style="color:rgb(102,0,102);">IReportEngine </span>engine.</p>
<pre class="_prettyXprint">
</pre>
<div>// Configure the Engine and start the Platform</div>
<div>DesignConfig config = new DesignConfig();</div>
<div> </div>
<div>config.setProperty("BIRT_HOME",</div>
<div>"D:/Downloads/birt-runtime-4_2_2/ReportEngine");</div>
<div>IDesignEngine engine = null;</div>
<div>try {</div>
<div>Platform.startup(config);</div>
<div>IDesignEngineFactory factory = (IDesignEngineFactory) Platform</div>
<div>.createFactoryObject(IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY);</div>
<div> </div>
<div>engine = factory.createDesignEngine(config);</div>
<div>} catch (Exception ex) {</div>
<div>ex.printStackTrace();</div>
<div>}</div>
0 -
<p>Turns out I already had a designHandle that I forgot about earlier in my code.</p>
<pre class="_prettyXprint _lang-">
designHandle = session.openDesign("path/to/reports/report.rptdesign"); </pre>
<p>then I modified the code from this post to look like this,</p>
<pre class="_prettyXprint _lang-">
ReportDesignHandle report = designHandle.getDesignHandle();
CssStyleSheetHandle css = report.openCssStyleSheet("Path/to/CSS/report.css");
report.addCss(css);</pre>
<p>question though. I am getting a warning that says that getDesignHandle is deprecated and the java doc says it is deprecated. So I was wondering if it was? I saw above mwilliams said that he did not think that it was deprecated I just want to make sure it is not.</p>
0 -
<p>This looks to be a bit tricky as the get getDesignHandle() method is showing as deprecated in some classes and not in others in the documentation. It does looks like the getDesignHandle() method has been deprecated in the org.eclipse.birt.report.model.api.DesignElementHandle class and has been replaced with getModuleHandle().</p>
<p> </p>
<p>As it looks to me like that is the class you are using, I would change up your code to be using getModuleHandle() instead so you aren't using a deprecated method.</p>
Warning No formatter is installed for the format ipb0 -
<p>That worked. I needed to cast it to (ReportDesignHandle)</p>
<pre class="_prettyXprint _lang-">
ReportDesignHandle report = (ReportDesignHandle) designHandle.getModuleHandle();
</pre>
<p>Now all I need to do is figure out my CSS. but I will start a new thread for that.</p>
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 151 General Questions
- 148 Thrust Services
- 57 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories