1. Go to this page and download the library: Download chrmorandi/yii2-jasper 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/ */
use chrmorandi\jasper\Jasper;
public function actionIndex()
{
// Set alias for sample directory
Yii::setAlias('example', '@vendor/chrmorandi/yii2-jasper/examples');
/* @var $jasper Jasper */
$jasper = Yii::$app->jasper;
// Compile a JRXML to Jasper
$jasper->compile(Yii::getAlias('@example') . '/hello_world.jrxml')->execute();
// Process a Jasper file to PDF and RTF (you can use directly the .jrxml)
$jasper->process(
Yii::getAlias('@example') . '/hello_world.jasper',
['php_version' => 'xxx'],
['pdf', 'rtf'],
false,
false
)->execute();
// List the parameters from a Jasper file.
$array = $jasper->listParameters(Yii::getAlias('@example') . '/hello_world.jasper')->execute();
// return pdf file
Yii::$app->response->sendFile(Yii::getAlias('@example') . '/hello_world.pdf');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.