---
title: Integration of Jasper Report – PHP CodeIgniter Web Framework
description: This is a tutorial about the integration of Jasper Report with PHP CodeIgniter Web Framework.
---

[e-Zest members share technology ideas to foster digital transformation.](https://blog.e-zest.com)

# [Integration of Jasper Report – PHP CodeIgniter Web Framework](https://blog.e-zest.com/integration-of-jaspersoft-report-php-codeigniter-web-framework)

 Written by [Archana Mulye](https://blog.e-zest.com/author/archana-mulye) | Feb 18, 2016, 1:50:45 PM

If you are dealing with billing or management projects where reporting is required with simple pdf formatted files, you need a quick way to interact with jasper reports along with tcpdf helper class file in PHP CodeIgniter Framework. Here’s how you can integrate Jasper Report with PHP CodeIgniter Web Framework:

Suppose you have a html (or any other) template file which has to be integrated with dynamic data into jasper report:

$template = file\_get\_contents("public/templates/template\_test.html");  

$this-\>jasperreport($template);

// Function which will interact with jasper helper class file and output a pdf file integrated with jasper report

function jasperreport($temp)

          {

// Loading class helper files for pdf and jasper report as used in a particular function. Otherwise, you can load it in a constructor

                   $this-\>load-\>helper("jasper");

                   $this-\>load-\>library("tcpdf");

                   $xml =  simplexml\_load\_file("public/report/test.jrxml");

                   $jasperXmlObj = new Jasper();

                   $ jasperXmlObj -\>debugsql=false;

                   // $data = array("parameter1"=\>$temp);

                   // print\_r($data);

                   $ jasperXmlObj -\>arrayParameter=array("parameter1"=\>$temp); // passing custom parameter for e.g, template

                   $ jasperXmlObj -\>xml\_dismantle($xml);

                   $ jasperXmlObj -\>transferDBtoArray("localhost","root","root","test"); // hostname, username, password, database name

                   $ jasperXmlObj -\>outpage("F");    //page output method I:standard output  D:Download file F: Save file

          }

A typical jasper report jrxml file will look like as follows:

\<?xml version="1.0" encoding="UTF-8"?\>

\<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="testbill" language="groovy" pageWidth="612" pageHeight="792" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"\>

          \<property name="ireport.zoom" value="1.0"/\>

          \<property name="ireport.x" value="0"/\>

          \<property name="ireport.y" value="0"/\>

          \<parameter name="parameter1" class="java.lang.String"\>

                   \<parameterDescription\>\<!\[CDATA\[\]\]\>\</parameterDescription\>

          \</parameter\>

          \<queryString\>

                   \<!\[CDATA\[select user\_email from user\_main limit 5\]\]\>

          \</queryString\>

          \<field name="user\_email" class="java.lang.String"/\>

          \<title\>

                   \<band height="15" splitType="Stretch"\>

                             \<staticText\>

                                      \<reportElement isPrintRepeatedValues="false" x="217" y="0" width="119" height="14"/\>

                                      \<textElement/\>

                                      \<text\>\<!\[CDATA\[Sample text for testing\]\]\>\</text\>

                             \</staticText\>

                   \</band\>

          \</title\>

          \<pageHeader\>

                   \<band height="5" splitType="Stretch"/\>

          \</pageHeader\>

          \<columnHeader\>

                   \<band splitType="Stretch"/\>

          \</columnHeader\>

          \<detail\>

                   \<band height="18" splitType="Stretch"\>

                             \<textField pattern=""\>

                                      \<reportElement isPrintRepeatedValues="false" x="83" y="0" width="92" height="16"\>

                                                \<property name="writeHTML" value="1"/\>

                                      \</reportElement\>

                                      \<textElement markup="html"\>

                                                \<font pdfEncoding="Cp1252" isPdfEmbedded="false"/\>

                                      \</textElement\>

                                       \<textFieldExpression\>\<!\[CDATA\[$P{parameter1}\]\]\>\</textFieldExpression\>

                             \</textField\>

                   \</band\>

          \</detail\>

\</jasperReport\>

In the jrxml file above, we are accessing our custom parameter passed from php code i.e. parameter1, using standard jasper report supported format,

\<!\[CDATA\[$P{parameter1}\]\]\>

Similarly, you can pass custom data to jrxml file from php and work with jasper report for dynamic data.

**Note:** To use helper/library files in core php, you can simply include those class files with include\_once function.

**Fill the below Form to download Library Files:**

[View full post](https://blog.e-zest.com/integration-of-jaspersoft-report-php-codeigniter-web-framework)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Archana Mulye"
  },
  "dateModified" : "2016-09-26T07:24:20.599Z",
  "datePublished" : "2016-02-18T13:50:45Z",
  "headline" : "Integration of Jasper Report – PHP CodeIgniter Web Framework",
  "image" : {
    "@type" : "ImageObject",
    "height" : 60,
    "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
    "width" : 60
  },
  "mainEntityOfPage" : "https://blog.e-zest.com/integration-of-jaspersoft-report-php-codeigniter-web-framework",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Blogs"
  }
}
```