Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Headers not printing while generating Word DOC(Headers not printing while generating Word DOC)
Headers not printing while generating Word DOC [message #546269] Mon, 12 July 2010 10:57 Go to next message
Neelesh is currently offline NeeleshFriend
Messages: 13
Registered: June 2010
Location: bangalore
Junior Member
Hey Everyone,
When I generate a simple report as a Word DOC the headers don't show up on any page.I have included some plain text under the header of the master page and under the the master page properties, there is property named "header/footer". I have unchecked the property "show header on first" so that headers get printed on all pages except first one. This works fine if I view the report as a pdf but not when as word doc.

If I check this check box "show header on first" then its working fine for pdf as well as word doc.

Any clue on how to fix this or any work around? Any parameter that I can pass from my java code which will set this property right for word doc?




Re: Headers not printing while generating Word DOC [message #546380 is a reply to message #546269] Mon, 12 July 2010 14:57 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Neelesh,

This appears to be a bug. Can you open a bugzilla entry for it?
As a work around can you use a page variable in the master page? Then
in script on the reports onPageEnd event enter a script like:

importPackage(Packages.java.lang);
//firstpage
if( reportContext.getGlobalVariable("mypghdr")== null ){
reportContext.setPageVariable("PageHdrLbl", "");
reportContext.setGlobalVariable("mypghdr", new Integer(1));
}else{
//next pages
reportContext.setPageVariable("PageHdrLbl", "My Page Header");
}

You will have to run this using the viewer /frameset mapping or a
separate run then render task. To test it launch in the viewer then
export to word. See attached report.

Jason

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.21"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
<property name="units">in</property>
<method
name="initialize">< ![CDATA[//reportContext.getDesignHandle().getElementByID()]] ></method>
<method name="onPageEnd"><![CDATA[importPackage(Packages.java.lang);
if( reportContext.getGlobalVariable("mypghdr")== null ){
reportContext.setPageVariable("PageHdrLbl", "");
reportContext.setGlobalVariable("mypghdr", new Integer(1));
}else{
reportContext.setPageVariable("PageHdrLbl", "My Page Header");
}]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<data-sources>
<oda-data-source
extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source"
id="7">
<property
name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver </property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
<property name="OdaConnProfileName"></property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
name="Data Set" id="8">
<list-property name="computedColumns">
<structure>
<property name="name">runningqty</property>
<property name="dataType">integer</property>
<property
name="aggregateFunction">RUNNINGSUM</property>
<list-property name="arguments">
<structure>
<property name="name">Expression</property>
<expression
name="value">row["QUANTITYORDERED"]</expression>
</structure>
</list-property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">ORDERNUMBER</property>
<text-property
name="displayName">ORDERNUMBER</text-property>
</structure>
<structure>
<property name="columnName">PRODUCTCODE</property>
<text-property
name="displayName">PRODUCTCODE</text-property>
</structure>
<structure>
<property name="columnName">QUANTITYORDERED</property>
<text-property
name="displayName">QUANTITYORDERED</text-property>
</structure>
<structure>
<property name="columnName">PRICEEACH</property>
<text-property
name="displayName">PRICEEACH</text-property>
</structure>
<structure>
<property name="columnName">ORDERLINENUMBER</property>
<text-property
name="displayName">ORDERLINENUMBER</text-property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">ORDERNUMBER</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTCODE</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">QUANTITYORDERED</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">PRICEEACH</property>
<property name="dataType">float</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">ORDERLINENUMBER</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">6</property>
<property name="name">runningqty</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">ORDERNUMBER</property>
<property name="nativeName">ORDERNUMBER</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTCODE</property>
<property name="nativeName">PRODUCTCODE</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">QUANTITYORDERED</property>
<property name="nativeName">QUANTITYORDERED</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">PRICEEACH</property>
<property name="nativeName">PRICEEACH</property>
<property name="dataType">float</property>
<property name="nativeDataType">8</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">ORDERLINENUMBER</property>
<property name="nativeName">ORDERLINENUMBER</property>
<property name="dataType">integer</property>
<property name="nativeDataType">5</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select *
from orderdetails
]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>ORDERNUMBER</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>10</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>ORDERNUMBER</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>ORDERNUMBER</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>PRODUCTCODE</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>15</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PRODUCTCODE</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PRODUCTCODE</design:label>
<design:formattingHints>
<design:displaySize>15</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>QUANTITYORDERED</design:name>
<design:position>3</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>10</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>QUANTITYORDERED</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>QUANTITYORDERED</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>PRICEEACH</design:name>
<design:position>4</design:position>
<design:nativeDataTypeCode>8</design:nativeDataTypeCode>
<design:precision>15</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PRICEEACH</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PRICEEACH</design:label>
<design:formattingHints>
<design:displaySize>22</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>ORDERLINENUMBER</design:name>
<design:position>5</design:position>
<design:nativeDataTypeCode>5</design:nativeDataTypeCode>
<design:precision>5</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>ORDERLINENUMBER</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>ORDERLINENUMBER</design:label>
<design:formattingHints>
<design:displaySize>6</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
<design:criteria/>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
</oda-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="showHeaderOnFirst">true</property>
<property name="showFooterOnLast">true</property>
<page-header>
<auto-text id="50">
<property name="type">page-variable</property>
<property name="pageVariable">PageHdrLbl</property>
</auto-text>
</page-header>
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="9">
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">ORDERNUMBER</property>
<text-property
name="displayName">ORDERNUMBER</text-property>
<expression name="expression"
type="javascript">dataSetRow["ORDERNUMBER"]</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">PRODUCTCODE</property>
<text-property
name="displayName">PRODUCTCODE</text-property>
<expression name="expression"
type="javascript">dataSetRow["PRODUCTCODE"]</expression >
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">QUANTITYORDERED</property>
<text-property
name="displayName">QUANTITYORDERED</text-property>
<expression name="expression"
type="javascript">dataSetRow["QUANTITYORDERED"]</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">PRICEEACH</property>
<text-property
name="displayName">PRICEEACH</text-property>
<expression name="expression"
type="javascript">dataSetRow["PRICEEACH"]</expression>
<property name="dataType">float</property>
</structure>
<structure>
<property name="name">ORDERLINENUMBER</property>
<text-property
name="displayName">ORDERLINENUMBER</text-property>
<expression name="expression"
type="javascript">dataSetRow["ORDERLINENUMBER"]</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">runningqty</property>
<text-property
name="displayName">runningqty</text-property>
<expression name="expression"
type="javascript">dataSetRow["runningqty"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<column id="43"/>
<column id="44"/>
<column id="45"/>
<column id="46"/>
<column id="47"/>
<column id="48"/>
<header>
<row id="10">
<cell id="11">
<label id="12">
<text-property
name="text">ORDERNUMBER</text-property>
</label>
</cell>
<cell id="13">
<label id="14">
<text-property
name="text">PRODUCTCODE</text-property>
</label>
</cell>
<cell id="15">
<label id="16">
<text-property
name="text">QUANTITYORDERED</text-property>
</label>
</cell>
<cell id="17">
<label id="18">
<text-property
name="text">PRICEEACH</text-property>
</label>
</cell>
<cell id="19">
<label id="20">
<text-property
name="text">ORDERLINENUMBER</text-property>
</label>
</cell>
<cell id="21">
<label id="22">
<text-property
name="text">runningqty</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="23">
<cell id="24">
<data id="25">
<property
name="resultSetColumn">ORDERNUMBER</property>
</data>
</cell>
<cell id="26">
<data id="27">
<property
name="resultSetColumn">PRODUCTCODE</property>
</data>
</cell>
<cell id="28">
<data id="29">
<property
name="resultSetColumn">QUANTITYORDERED</property>
</data>
</cell>
<cell id="30">
<data id="31">
<property
name="resultSetColumn">PRICEEACH</property>
</data>
</cell>
<cell id="32">
<data id="33">
<property
name="resultSetColumn">ORDERLINENUMBER</property>
</data>
</cell>
<cell id="34">
<data id="35">
<property
name="resultSetColumn">runningqty</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="36">
<cell id="37"/>
<cell id="38"/>
<cell id="39"/>
<cell id="40"/>
<cell id="41"/>
<cell id="42"/>
</row>
</footer>
</table>
</body>
<property name="pageVariables">
<variable-element name="PageHdrLbl">
<expression name="value" type="javascript">""</expression>
<property name="type">page</property>
</variable-element>
</property>
</report>


On 7/12/2010 6:57 AM, Neelesh wrote:
> Hey Everyone,
> When I generate a simple report as a Word DOC the headers don't show up
> on any page.I have included some plain text under the header of the
> master page and under the the master page properties, there is property
> named "header/footer". I have unchecked the property "show header on
> first" so that headers get printed on all pages except first one. This
> works fine if I view the report as a pdf but not when as word doc.
>
> If I check this check box "show header on first" then its working fine
> for pdf as well as word doc.
>
> Any clue on how to fix this or any work around? Any parameter that I can
> pass from my java code which will set this property right for word doc?
>
>
>
Re: Headers not printing while generating Word DOC [message #546416 is a reply to message #546380] Mon, 12 July 2010 17:14 Go to previous messageGo to next message
Neelesh is currently offline NeeleshFriend
Messages: 13
Registered: June 2010
Location: bangalore
Junior Member
Alright Jason I will try this and also open a bug for this in bugzilla. Again any idea when can we expect a fix for the same?
Re: Headers not printing while generating Word DOC [message #546426 is a reply to message #546416] Mon, 12 July 2010 17:24 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Neelesh,

I really can not give you an estimate on fix times. Obviously the
quicker we get the bug entry entered the faster the fix time. It will
really depend on difficult it is to fix. Once you log the bug one of
the dev team members should mark the estimated version it will be fixed in.

Jason

On 7/12/2010 1:14 PM, Neelesh wrote:
> Alright Jason I will try this and also open a bug for this in bugzilla.
> Again any idea when can we expect a fix for the same?
Re: Headers not printing while generating Word DOC [message #547998 is a reply to message #546380] Tue, 20 July 2010 11:18 Go to previous messageGo to next message
Neelesh is currently offline NeeleshFriend
Messages: 13
Registered: June 2010
Location: bangalore
Junior Member
Jason,

I tried your solution and launched in the viewer then
export to word. It works fine... But I want to generate it programmatically, So i tried separate run then render task. It fails in this case.. Below is my java code for run and render task separately








import java.io.OutputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;

import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.*;
import org.eclipse.birt.report.engine.api.script.*;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
import org.eclipse.birt.report.model.api.elements.DesignChoiceConst ants;
import org.eclipse.birt.report.model.api.elements.structures.HideRu le;
import org.eclipse.birt.report.model.core.DesignElement;
import org.eclipse.birt.report.model.metadata.ElementPropertyDefn;
import org.eclipse.birt.report.engine.dataextraction.*;
import org.eclipse.birt.report.engine.*;
import org.eclipse.birt.report.model.*;
import org.eclipse.birt.report.model.api.*;

public class ReportBuilder
{

public static void main(String[] args) {
try
{
executeReport( );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
public static void executeReport()throws EngineException
{
System.out.println("in execute----");
IReportEngine engine=null;
EngineConfig config = null;
try{
config = new EngineConfig( );
config.setEngineHome( "C:/birt-runtime-2_6_0/birt-runtime-2_6_0/ReportEngine" );
config.setLogConfig(null, Level.FINE);

Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
engine.changeLogLevel( Level.WARNING );

}catch( Exception ex){
ex.printStackTrace();
}


//Create the report engine
HTMLEmitterConfig emitterConfig = new HTMLEmitterConfig( );
emitterConfig.setActionHandler( new HTMLActionHandler( ) );
HTMLServerImageHandler imageHandler = new HTMLServerImageHandler( );
emitterConfig.setImageHandler( imageHandler );
config.getEmitterConfigs( ).put( "html", emitterConfig ); //$NON-NLS-1$

IReportRunnable design = null;

// design = engine.openReportDesign("C:/test/2.1/toc/TOCTest.rptdesign");
design = engine.openReportDesign(" D:/Cup_Latest_Workspace/printdocs/resources/Map_Template.rpt design ");
//parseParams( engine, design, params );
//Create task to run the report - use the task to execute and run the report,
// System.out.println("1111000000000000000000000000");
IRunTask task = engine.createRunTask(design);
/*task.setParameterValues( params );
task.setParameterValue("key", selectedDocs);
task.setParameterValue("dataBaseName", database);
task.setParameterValue("flags", flagMap);*/

//Create rptdocument
// task.run("c:/test/2.1/toc/TOCTest.rptdocument");
//System.out.println("111111111111111111111111");
task.run(" D:/Cup_Latest_Workspace/printdocs/resources/Map_Template.rpt document ");
// System.out.println("11113333333333333311111111111111111111");
//Open rptdocument
IReportDocument rptdoc = engine.openReportDocument(" D:/Cup_Latest_Workspace/printdocs/resources/Map_Template.rpt document ");
//Get the top level TOC Node
TOCNode tn = rptdoc.findTOC(null);
List children = tn.getChildren();

//Display top level children
if( children != null && children.size() >0 )
{
for( int i = 0; i < children.size(); i++)
{
TOCNode child = ( TOCNode )children.get(i);
System.out.println( "Node ID " + child.getNodeID());

System.out.println( "Node Display String " + child.getDisplayString());
System.out.println( "Node Bookmark " + child.getBookmark());
}
}

//Create Render Task
IRenderTask rtask = engine.createRenderTask(rptdoc);



//Set Render context to handle url and image locataions
HTMLRenderContext renderContext = new HTMLRenderContext();
//Set the Base URL for all actions
renderContext.setBaseURL("http://localhost/");
//Tell the Engine to prepend all images with this URL - Note this requires using the HTMLServerImageHandler
renderContext.setBaseImageURL("http://localhost/myimages");
//Tell the Engine where to write the images to
renderContext.setImageDirectory("C:/xampplite/htdocs/myimages ");
//Tell the Engine what image formats are supported. Note you must have SVG in the string
//to render charts in SVG.
renderContext.setSupportedImageFormats("JPG;PNG;BMP;SVG");
HashMap<String, HTMLRenderContext> contextMap = new HashMap<String, HTMLRenderContext>();
contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );
rtask.setAppContext( contextMap );


//Set rendering options - such as file or stream output,
//output format, whether it is embeddable, etc
HTMLRenderOption options = new HTMLRenderOption();

//Remove HTML and Body tags
//options.setEmbeddable(true);

//Set ouptut location
options.setOutputFileName("C:/test/2.1/output_test.doc");

//Set output format
options.setOutputFormat("doc");

//options.setOutputFormat(format);
rtask.setRenderOption(options);
//rtask.setPageNumber(1);
//rtask.setPageNumber(i);
//run the report and destroy the engine
/*for(int i=1;i<10;i++)
{

}*/
/* rtask.setPageRange("6");
rtask.getPageNumber(null);*/
// rtask.setPageRange("1-6,6");
/* for(int j=0;j<2;j++)
{*/
// rtask.setPageNumber(5);
rtask.render();
// }

//render the report and destroy the engine
//Note - If the program stays resident do not shutdown the Platform or the Engine

rtask.close();
rptdoc.close();
task.close();
engine.shutdown();
Platform.shutdown();
System.out.println("Finished");
}
/**
* @param args
*/

}
Re: Headers not printing while generating Word DOC [message #548125 is a reply to message #547998] Tue, 20 July 2010 17:39 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

When you do your render task set the html pagination option to true.

IReportDocument document = null;
//Open the report design
document = engine.openReportDocument("output/resample/ps.rptdocument");
IRenderOption options = new RenderOption();
options.setOutputFormat("doc");
options.setOutputFileName("output/resample/ps.doc");
options.setOption( IRenderOption.HTML_PAGINATION,
Boolean.TRUE );

IRenderTask task = engine.createRenderTask(document);
task.setRenderOption(options);
task.render();
task.close();
document.close();
Jason

On 7/20/2010 7:18 AM, Neelesh wrote:
> Jason,
>
> I tried your solution and launched in the viewer then export to word. It
> works fine... But I want to generate it programmatically, So i tried
> separate run then render task. It fails in this case.. Below is my java
> code for run and render task separately
>
>
>
>
>
>
>
>
> import java.io.OutputStream;
> import java.util.Collection;
> import java.util.HashMap;
> import java.util.Iterator;
> import java.util.List;
> import java.util.logging.Level;
>
> import org.eclipse.birt.core.framework.Platform;
> import org.eclipse.birt.report.engine.api.*;
> import org.eclipse.birt.report.engine.api.script.*;
> import org.eclipse.birt.report.model.api.ReportDesignHandle;
> import org.eclipse.birt.report.model.api.StructureFactory;
> import org.eclipse.birt.report.model.api.elements.DesignChoiceConst ants;
> import org.eclipse.birt.report.model.api.elements.structures.HideRu le;
> import org.eclipse.birt.report.model.core.DesignElement;
> import org.eclipse.birt.report.model.metadata.ElementPropertyDefn;
> import org.eclipse.birt.report.engine.dataextraction.*;
> import org.eclipse.birt.report.engine.*;
> import org.eclipse.birt.report.model.*;
> import org.eclipse.birt.report.model.api.*;
>
> public class ReportBuilder
> {
>
> public static void main(String[] args) {
> try
> {
> executeReport( );
> }
> catch ( Exception e )
> {
> e.printStackTrace();
> }
> }
> public static void executeReport()throws EngineException
> {
> System.out.println("in execute----");
> IReportEngine engine=null;
> EngineConfig config = null;
> try{
> config = new EngineConfig( );
> config.setEngineHome(
> "C:/birt-runtime-2_6_0/birt-runtime-2_6_0/ReportEngine" );
> config.setLogConfig(null, Level.FINE);
>
> Platform.startup( config );
> IReportEngineFactory factory = (IReportEngineFactory) Platform
> .createFactoryObject(
> IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
> engine = factory.createReportEngine( config );
> engine.changeLogLevel( Level.WARNING );
>
> }catch( Exception ex){
> ex.printStackTrace();
> }
>
> //Create the report engine
> HTMLEmitterConfig emitterConfig = new HTMLEmitterConfig( );
> emitterConfig.setActionHandler( new HTMLActionHandler( ) );
> HTMLServerImageHandler imageHandler = new HTMLServerImageHandler( );
> emitterConfig.setImageHandler( imageHandler );
> config.getEmitterConfigs( ).put( "html", emitterConfig ); //$NON-NLS-1$
>
> IReportRunnable design = null;
>
> // design =
> engine.openReportDesign("C:/test/2.1/toc/TOCTest.rptdesign"); design =
> engine.openReportDesign("
> D:/Cup_Latest_Workspace/printdocs/resources/Map_Template.rpt design ");
> //parseParams( engine, design, params );
> //Create task to run the report - use the task to execute and run the
> report,
> // System.out.println("1111000000000000000000000000");
> IRunTask task = engine.createRunTask(design); /*task.setParameterValues(
> params );
> task.setParameterValue("key", selectedDocs);
> task.setParameterValue("dataBaseName", database);
> task.setParameterValue("flags", flagMap);*/
>
> //Create rptdocument
> // task.run("c:/test/2.1/toc/TOCTest.rptdocument");
> //System.out.println("111111111111111111111111");
> task.run(" D:/Cup_Latest_Workspace/printdocs/resources/Map_Template.rpt
> document ");
> // System.out.println("11113333333333333311111111111111111111");
> //Open rptdocument
> IReportDocument rptdoc = engine.openReportDocument("
> D:/Cup_Latest_Workspace/printdocs/resources/Map_Template.rpt document ");
> //Get the top level TOC Node
> TOCNode tn = rptdoc.findTOC(null);
> List children = tn.getChildren();
>
> //Display top level children
> if( children != null && children.size() >0 )
> {
> for( int i = 0; i < children.size(); i++)
> {
> TOCNode child = ( TOCNode )children.get(i);
> System.out.println( "Node ID " + child.getNodeID());
>
> System.out.println( "Node Display String " + child.getDisplayString());
> System.out.println( "Node Bookmark " + child.getBookmark());
> }
> }
>
> //Create Render Task
> IRenderTask rtask = engine.createRenderTask(rptdoc);
>
>
>
> //Set Render context to handle url and image locataions
> HTMLRenderContext renderContext = new HTMLRenderContext();
> //Set the Base URL for all actions
> renderContext.setBaseURL("http://localhost/");
> //Tell the Engine to prepend all images with this URL - Note this
> requires using the HTMLServerImageHandler
> renderContext.setBaseImageURL("http://localhost/myimages");
> //Tell the Engine where to write the images to
> renderContext.setImageDirectory("C:/xampplite/htdocs/myimages ");
> //Tell the Engine what image formats are supported. Note you must have
> SVG in the string //to render charts in SVG.
> renderContext.setSupportedImageFormats("JPG;PNG;BMP;SVG");
> HashMap<String, HTMLRenderContext> contextMap = new HashMap<String,
> HTMLRenderContext>();
> contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
> renderContext );
> rtask.setAppContext( contextMap );
>
>
> //Set rendering options - such as file or stream output, //output
> format, whether it is embeddable, etc
> HTMLRenderOption options = new HTMLRenderOption();
>
> //Remove HTML and Body tags
> //options.setEmbeddable(true);
>
> //Set ouptut location
> options.setOutputFileName("C:/test/2.1/output_test.doc");
>
> //Set output format
> options.setOutputFormat("doc");
> //options.setOutputFormat(format);
> rtask.setRenderOption(options);
> //rtask.setPageNumber(1);
> //rtask.setPageNumber(i);
> //run the report and destroy the engine
> /*for(int i=1;i<10;i++)
> {
> }*/
> /* rtask.setPageRange("6");
> rtask.getPageNumber(null);*/
> // rtask.setPageRange("1-6,6");
> /* for(int j=0;j<2;j++)
> {*/
> // rtask.setPageNumber(5);
> rtask.render();
> // }
>
> //render the report and destroy the engine
> //Note - If the program stays resident do not shutdown the Platform or
> the Engine rtask.close();
> rptdoc.close();
> task.close();
> engine.shutdown();
> Platform.shutdown();
> System.out.println("Finished");
> } /**
> * @param args
> */
>
> }
Previous Topic:Text wrapping in Birt
Next Topic:include chart in a jsp page
Goto Forum:
  


Current Time: Thu Apr 25 14:33:03 GMT 2024

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

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

Back to the top