hboie/jasper-report-bundle

Symfony 2 Bundle integrating the Jaspersoft REST v2 client (jaspersoft/rest-client)

Installs: 671

Dependents: 0

Suggesters: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

v0.2 2016-02-20 23:28 UTC

README

The JasperReportBundle requires jaspersoft/rest-client and provides an JasperReport-Client as service in the Symfony service container.

Installation

1 Add bundle to composer.json:

    composer require hboie/jasper_report_bundle

2 Register bundle in app/AppKernel.php:

    $bundle = [
            ...
    new Hboie\JasperReportBundle\HboieJasperReportBundle(),
            ...
    ];

3 Add parameter to app/config/config.yml

    hboie_jasper_report:
        host:      "%jasper_host%"
        username:  "%jasper_user%"
        password:  "%jasper_password%"
        org_id:    "%jasper_org_id%"

4 Add a dummy configuration in app/config/paramters.yml.dist

    jasper_host: http://localhost:8080/jasperserver
    jasper_user: jasperadmin
    jasper_password: jasperadmin
    jasper_org_id:

5 Add your own configuration in app/config/paramters.yml

Usage

You can now access the Client object via the Symfony service jasperreport.client:

    $client = $this->get('jasperreport.client');

or directly access the ReportService using the Symfony service jasperreport.reportservice:

    $report = $this->get('jasperreport.reportservice')->runReport('/reports/TestReport', 'pdf');

So a controller giving back a pdf-report would look like

    public function reportAction(Request $request)
    {
        $report = $this->get('jasperreport.reportservice')->runReport('/reports/TestReport', 'pdf');

        $response = new Response($report);
        $response->headers->set('Content-type', 'application/pdf');
        $response->headers->set('Content-Disposition', 'inline; filename=Report.pdf');
        $response->headers->set('Cache-Control', 'must-revalidate');

        return $response;
    }