Jump to content
Changes to the Jaspersoft community edition download ×

Recommended Posts

By: Henry - hrdik

hrdik

2004-11-03 23:44

Hi,

 

We try to integrate the jasper report with php using the following code.

 

However, when runing the report, we can't use the jasper report viewer and also can't generate pdf file directly.

 

Please help Regards,

Hrdik

 

//======================

PHP Version 4.1.0

System Windows 95/98 4.10

Java version=1.4.0-beta3

 

//====================

 

extension=php_java.dll

java.class.path = "E:Program FilesPhpextphp_java.jar;E:Program FilesPhpextitext-0.96.jar;E:Program FilesPhpextjasperreports-0.4.6.jar;E:jdklib;e:program filesphpext;e:program filesphpext"

java.home = e:jdk

java.library = e:jdkjrebinserverjvm.dll

java.library.path = e:program filesphpext;

 

//=================================================

//=================================================

 

/******************************************************************************

* JasperReport <-> PHP Connector © 2003 by Giulio Toffoli

* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,

* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND

* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE

* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,

* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-

* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS

* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON

* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF

* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

********************************************************************************/

import dori.jasper.engine.*;

import dori.jasper.view.*;

 

public class PHPJRConnector

{

 

public static String run(String srcFileName, String dstFileName)

{

try {

dori.jasper.engine.JasperPrint print=null;

dori.jasper.engine.JRExporter exporter=null;

print = dori.jasper.engine.JasperFillManager.fillReport(

srcFileName,

null,new JREmptyDataSource());

exporter = new dori.jasper.engine.export.JRPdfExporter();

exporter.setParameter(

JRExporterParameter.OUTPUT_FILE_NAME,dstFileName);

exporter.setParameter(

JRExporterParameter.JASPER_PRINT,print);

exporter.exportReport();

 

return "YES";

} catch (Exception ex)

{

return "ERROR!";

}

}

}

 

 

//=================================================

//=================================================

 

<?php

 

/******************************************************************************

* JasperReport <-> PHP Connector © 2003 by Giulio Toffoli

*

* THIS SOFTWARE IS PROVIDED ``AS IS"" AND ANY EXPRESSED OR IMPLIED

WARRANTIES,

* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF

MERCHANTABILITY AND

* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT

SHALL THE

* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY

DIRECT,

* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES

(INCLU-

* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;

LOSS

* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED

AND ON

* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR

TORT

* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF

THE USE OF

* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

********************************************************************************/

// Create a new instance of my add hoc class

$myFiller = new Java("PHPJRConnector");

$path_to_jasper_compiled =

"D:\rfw\";

$path_to_jasper_filled =

"D:\rfw\";

 

// Pass to the run method the compiled print file to fill and

// the output file...

$result =

$myFiller->run($path_to_jasper_compiled."SampleOrder.jasper",$path_to_jasper_filled."docxxx.pdf");

 

if ($result == "YES")

{

header("Location: docxxx.pdf");

echo "File generated succesfully!";

}

else

echo "Error!";

 

 

>

 

 

 

 

 

By: Henry - hrdik

RE: PHP jasper report integration

2004-11-04 00:17

By the way, we try to use this document:

 

https://sourceforge.net/mailarchive/message.php?msg_id=3633194

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...