PHP code example of hboie / jasper-report-bundle

1. Go to this page and download the library: Download hboie/jasper-report-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hboie / jasper-report-bundle example snippets


    use Symfony\Component\HttpFoundation\Request;
    use Hboie\JasperReportBundle\ReportService;

    public function reportAction(Request $request, ReportService $reportService)
    {
        $report = $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;
    }

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

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

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

    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;
    }

    php bin/console jasper:export:resource <UriOfResource> <Filename> <SkipDependentResources>