<?php
require_once 'startup.php';
$engine = startup();
$root_directory = zget("/config/root");
$design_file = $root_directory."/samples/hello_world.rptdesign";
$design = $engine->openReportDesign($design_file);
$task = $engine->createRunAndRenderTask($design);
$task->validateParameters();
java_import("org.eclipse.birt.report.engine.api.HTMLRenderOption");
$generated_report_file = tempnam(sys_get_temp_dir(), 'report');
$options = new HTMLRenderOption();
$options->setOutputFileName($generated_report_file);
$options->setOutputFormat("html");
$task->setRenderOption($options);
$task->run();
$task->close();
echo file_get_contents($generated_report_file);
unlink($generated_report_file);
?>
And the include file that configures the BIRT runtime is as follows:
<?php
function startup() {
zpost("/app#lock", "/engine");
$engine = zget("/tmp/factory");
if ($engine != NULL) {
zpost("/app#unlock", "/engine");
return $engine; // Did someone else get in first?
}
$root_directory = zget("/config/root");
$report_directory = $root_directory."/birt-runtime-2_3_1/ReportEngine";
$log_directory = zget("/config/appLogDir");
java_import("org.eclipse.birt.core.framework.Platform");
java_import("java.util.logging.Level");
java_import("org.eclipse.birt.report.engine.api.EngineConfig");
java_import("org.eclipse.birt.report.engine.api.IReportEngineFactory");
$config = new EngineConfig();
$config->setBIRTHome($report_directory);
$config->setLogConfig($log_directory, Level::$SEVERE);
Platform::startup($config);
$factory = Platform::createFactoryObject(
IReportEngineFactory::$EXTENSION_REPORT_ENGINE_FACTORY);
// Store in process wide non persistent zone
$engine = $factory->createReportEngine($config);
zput("/tmp/factory", $engine);
// Unlock when we are finished!
zpost("/app#unlock", "/engine");
return $engine;
}
?>
0 comments:
Post a Comment