Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » PHP and JavaBridge - run report and show print and export buttons(Showing a report on PHP web page using JavaBridge, but not being able to show buttons)
PHP and JavaBridge - run report and show print and export buttons [message #717220] Fri, 19 August 2011 15:53 Go to next message
PTPro  is currently offline PTPro Friend
Messages: 9
Registered: August 2011
Junior Member
Hi all,

I have a web page made in PHP and I've installed tomcat with birt viewer and also installed JavaBridge.

I'm able to view my report in the PHP page if I call it using the Birt Viewer:

<?php 
  $dest = "http://localhost:8080/birt-viewer/frameset?__report=MyReport.rptdesign";
				
  echo "<script language=\"javascript\">window.open('".$dest."');</script>";

?>


And this works perfectly, shows the report with all options (print, export...). However, I want to consume the report using JavaBridge and not the Birt Viewer.
I'm currently doing this:

<?php

 if (!(get_cfg_var('java.web_inf_dir'))) {
  define ("JAVA_HOSTS", "127.0.0.1:8081");
  define ("JAVA_SERVLET", "../../tomcat/webapps/JavaBridge/JavaBridge.phpjavabridge");
 }
			
 $pth = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
 $path_parts = pathinfo($pth);
 $imageURLPrefix = $path_parts['dirname'] ."/images/";
 require_once("../../tomcat/webapps/JavaBridge/java/Java.inc");

 session_start(); 

 $here = getcwd();


 $ctx = java_context()->getServletContext();
 $birtReportEngine = java("org.eclipse.birt.php.birtengine.BirtEngine")->getBirtEngine($ctx);
			  java_context()->onShutdown(java("org.eclipse.birt.php.birtengine.BirtEngine")->getShutdownHook());

 try{


  $report = $birtReportEngine->openReportDesign("${here}/TopNPercent.rptdesign");
  $task = $birtReportEngine->createRunAndRenderTask($report);
  $task->setParameterValue("Top Count", new java("java.lang.Integer", 6));

  $taskOptions = new java("org.eclipse.birt.report.engine.api.HTMLRenderOption");
  $outputStream = new java("java.io.ByteArrayOutputStream");
  $taskOptions->setOutputStream($outputStream);
  $taskOptions->setOutputFormat("html");
  $ih = new java( "org.eclipse.birt.report.engine.api.HTMLServerImageHandler");
  $taskOptions->setImageHandler($ih);
  $taskOptions->setEnableAgentStyleEngine(true);
  $taskOptions->setBaseImageURL($imageURLPrefix . session_id());
  $taskOptions->setImageDirectory($here . "/images/" . session_id());

  $task->setRenderOption( $taskOptions );
  $task->run();
  $task->close();

 } catch (JavaException $e) {
   echo $e; //"Error Calling BIRT";
				
 }

 echo $outputStream;

?>



This displays the report correctly, but does not display the print and export buttons. Is there any way to call the report using JavaBridge and showing the buttons or do I really have to make this using the Birt Viewer?

Thank you for your help!
Re: PHP and JavaBridge - run report and show print and export buttons [message #717243 is a reply to message #717220] Fri, 19 August 2011 16:52 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

The viewer is built using AJAX and JSP fragments and is not currently in
the Report Engine API, so if you need those things then you will either
have to recreate them or use the existing viewer.

Jason

On 8/19/2011 11:53 AM, PTPro wrote:
> Hi all,
>
> I have a web page made in PHP and I've installed tomcat with birt viewer
> and also installed JavaBridge.
>
> I'm able to view my report in the PHP page if I call it using the Birt
> Viewer:
>
>
> <?php $dest =
> "http://localhost:8080/birt-viewer/frameset?__report=MyReport.rptdesign";
>
> echo "<script language=\"javascript\">window.open('".$dest."');</script>";
>
> ?>
>
>
> And this works perfectly, shows the report with all options (print,
> export...). However, I want to consume the report using JavaBridge and
> not the Birt Viewer.
> I'm currently doing this:
>
>
> <?php
>
> if (!(get_cfg_var('java.web_inf_dir'))) {
> define ("JAVA_HOSTS", "127.0.0.1:8081");
> define ("JAVA_SERVLET",
> "../../tomcat/webapps/JavaBridge/JavaBridge.phpjavabridge");
> }
>
> $pth = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
> $path_parts = pathinfo($pth);
> $imageURLPrefix = $path_parts['dirname'] ."/images/";
> require_once("../../tomcat/webapps/JavaBridge/java/Java.inc");
>
> session_start();
> $here = getcwd();
>
>
> $ctx = java_context()->getServletContext();
> $birtReportEngine =
> java("org.eclipse.birt.php.birtengine.BirtEngine")->getBirtEngine($ctx);
> java_context()->onShutdown(java("org.eclipse.birt.php.birtengine.BirtEngine")->getShutdownHook());
>
>
> try{
>
>
> $report =
> $birtReportEngine->openReportDesign("${here}/TopNPercent.rptdesign");
> $task = $birtReportEngine->createRunAndRenderTask($report);
> $task->setParameterValue("Top Count", new java("java.lang.Integer", 6));
>
> $taskOptions = new
> java("org.eclipse.birt.report.engine.api.HTMLRenderOption");
> $outputStream = new java("java.io.ByteArrayOutputStream");
> $taskOptions->setOutputStream($outputStream);
> $taskOptions->setOutputFormat("html");
> $ih = new java(
> "org.eclipse.birt.report.engine.api.HTMLServerImageHandler");
> $taskOptions->setImageHandler($ih);
> $taskOptions->setEnableAgentStyleEngine(true);
> $taskOptions->setBaseImageURL($imageURLPrefix . session_id());
> $taskOptions->setImageDirectory($here . "/images/" . session_id());
>
> $task->setRenderOption( $taskOptions );
> $task->run();
> $task->close();
>
> } catch (JavaException $e) {
> echo $e; //"Error Calling BIRT";
>
> }
>
> echo $outputStream;
>
> ?>
>
>
>
> This displays the report correctly, but does not display the print and
> export buttons. Is there any way to call the report using JavaBridge and
> showing the buttons or do I really have to make this using the Birt Viewer?
>
> Thank you for your help!
Re: PHP and JavaBridge - run report and show print and export buttons [message #718135 is a reply to message #717243] Tue, 23 August 2011 11:31 Go to previous messageGo to next message
PTPro  is currently offline PTPro Friend
Messages: 9
Registered: August 2011
Junior Member
Thank you Jason.

Best regards
Re: PHP and JavaBridge - run report and show print and export buttons [message #730816 is a reply to message #718135] Thu, 29 September 2011 08:55 Go to previous message
karvesh ghunsam is currently offline karvesh ghunsamFriend
Messages: 95
Registered: July 2011
Member
Hi PTPro

I have the same issue when it comes with the print and export buttons. I had to create a panel with the buttons for printing and export to pdf, word and excel in Javascript. I also include the page count and move next or previous pages buttons.

The only issue here is the direct printing of the report without having to pass by pdf exports. I simply flush the iframe to the printer where the report is being displayed.
Unfortunately it is flushed as one single HTML page and the setting of the master page is not applied..

Am still trying to figure out how to solve this issue

Karvesh
Previous Topic:Error in cross tab
Next Topic:Get the Sundays ( dates) from a date range
Goto Forum:
  


Current Time: Thu Apr 25 22:39:33 GMT 2024

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

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

Back to the top