PHP code example of simplisti / jasper-starter

1. Go to this page and download the library: Download simplisti/jasper-starter 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/ */

    

simplisti / jasper-starter example snippets





mplisti\Lib\JasperStarter\Reporter;

use Simplisti\Lib\JasperStarter\Option\OptionParameter as oParams;

use Simplisti\Lib\JasperStarter\Option\OptionDb as oDbConn;
use Simplisti\Lib\JasperStarter\Option\OptionOutputType as oOutputType;

// Use aggregate DB connection object
$optionDb = new oDbConn('simplisti', 'root');

$options[] = new oOutputType('pdf');
$options = array_merge($options, (array)$optionDb);

$parameters = new oParams([
    'ID_ORGANIZATION' => 254,
    'ID_WORKORDER' => 112203
]);

$outputFile = '';

$reporter = new Reporter('/opt/jasperstarter/bin/jasperstarter'); // NOTE: Manually provide jasperstarter?!? Need PATH= otherwise

$reporter->compile('/vagrant/devlib/tpl/cert.jrxml');
$reporter->process('/vagrant/devlib/tpl/cert.jasper', $outputFile, $options, $parameters);

$parameters = [];
$reporter->listParameters('tpl/cert.jrxml', $parameters);

print_r($parameters);