|
Re: How to integrate birt in Zend Ce with the help of Zend JavaBridge without tomcat server? [message #806287 is a reply to message #805070] |
Fri, 24 February 2012 19:47 |
|
Justin
If you download the 3.7 runtime you should be able to build a command
line app that runs the reports. Attached is a simple example. To build
the class make sure you have the jars from the runtime
download/reportengine/lib directory in the classpath. Once built you
should be able to call it the same way as the simple Java app. This
sample does a platform startup and shutdown which is generally not a
good idea if you are going to generate a lot of reports. A better
solution is to wrap the Platform startup and report engine creation in a
singleton that starts when you server starts up, then use the engine to
create a new task per request.
import java.util.logging.Level;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EXCELRenderOption;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
import org.eclipse.birt.report.engine.api.RenderOption;
import org.eclipse.birt.report.engine.api.impl.RunAndRenderTask;
import org.eclipse.birt.report.engine.api.script.IReportContext;
public class RunAndRenderTaskTest {
public void runReport() throws EngineException
{
RunAndRenderTask task=null;
IReportEngine engine=null;
EngineConfig config = null;
try{
config = new EngineConfig( );
//config.setLogConfig("c:/dwn", Level.SEVERE);
//config.setResourcePath("C:/work/workspaces/3.7.1workspaces/BIRT
Metal/APIs/resources");
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(
IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
IReportRunnable design = null;
//Open the report design
design = engine.openReportDesign("Reports/testlibrary.rptdesign");
task = (RunAndRenderTask) engine.createRunAndRenderTask(design);
IReportContext irc = task.getReportContext();
//task.setParameterValue("Top Count", (new Integer(5)));
//task.validateParameters();
//HTMLRenderOption options = new HTMLRenderOption();
//options.setImageDirectory("./");
//options.setOutputFileName("output/resample/external.html");
//options.setOutputFormat("html");
//options.setEmbeddable(false);
//options.setEnableMetadata(true);
//options.setEnableInlineStyle(false);
//options.setEnableAgentStyleEngine(true);
//options.setEnableCompactMode(true);
//PDFRenderOption options = new PDFRenderOption();
//options.setOutputFileName("output/resample/hidefooter.pdf");
//options.setSupportedImageFormats("PNG;GIF;JPG;BMP;SWF;SVG");
//options.setOutputFormat("pdf");
//EXCELRenderOption options = new EXCELRenderOption();
//options.setOutputFormat("xls");
//options.setOutputFileName("output/resample/customers.xls");
//options.setWrappingText(true);
HTMLRenderOption options = new HTMLRenderOption();
//options.setImageHandler(new HTMLServerImageHandler());
options.setSupportedImageFormats("JPG;PNG;BMP;SVG;GIF");
options.setOutputFileName("output/resample/testlibrary.html");
options.setOutputFormat("html");
//options.setOutputFormat("ppt");
task.setRenderOption(options);
task.run();
irc = task.getReportContext();
task.close();
engine.destroy();
}catch( Exception ex){
ex.printStackTrace();
}
Platform.shutdown( );
System.out.println("Finished");
}
/**
* @param args
*/
public static void main(String[] args) {
try
{
RunAndRenderTaskTest ex = new RunAndRenderTaskTest( );
ex.runReport();
System.exit(0);
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
Jason
On 2/23/2012 4:52 AM, justin dominic wrote:
> i have googled to find any implementations of birt integration in zend
> framework with birt reporting but found none .
>
> i have installed Zend JavaBridge and tested it by running a java program
> succesfully
>
> has shown in this link below ..
>
> files.zend.com/help/Zend-Server/working_with_the_java_bridge.htm
>
> when i try to run any of the birts sample report
>
> given in the link below ..
>
> files.zend.com/help/Zend-Platform-i5/birt_apis.htm
>
> it shows internal server error
>
> can anyone show me how to run a birt report in zend CE with the help of
> Zend java bridge using tomcat server is not an option for me .
>
> please help me has anyone implemented it ? :(
|
|
|
|
Powered by
FUDForum. Page generated in 0.03993 seconds