PHPJasper (Gerar relatorio, comunicação com o banco)
Oi pessoal, estou com um probleminha. Estou tentando gerar um relatório através do PHPJasper (https://github.com/PHPJasper/phpjasper),
Quando faço o teste de gerar o arquivo de teste hellow_world.jrxml funciona normalmente, porém quando tento gerar um pdf através da conexão com o banco da um erro:
Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: Your report has an error and couldn 't be processed!\ Try to output the command using the function `output();` and run it manually in the console. in C:\xampp\htdocs\html2\phpjasper-master\vendor\geekcom\phpjasper\src\PHPJasper.php:235 Stack trace: #0 C:\xampp\htdocs\html2\phpjasper-master\test.php(33): PHPJasper\PHPJasper->execute() #1 thrown in C:\xampp\htdocs\html2\phpjasper-master\vendor\geekcom\phpjasper\src\PHPJasper.php on line 235
Segui toda a documentação, videos e etc... Porém não tive êxito, alguém poderia dar um help?
Arquivo de teste SEM conexão com banco (RODANDO OK!)
Arquivo COM conexão com o banco (ERRO)
Quando faço o teste de gerar o arquivo de teste hellow_world.jrxml funciona normalmente, porém quando tento gerar um pdf através da conexão com o banco da um erro:
Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: Your report has an error and couldn 't be processed!\ Try to output the command using the function `output();` and run it manually in the console. in C:\xampp\htdocs\html2\phpjasper-master\vendor\geekcom\phpjasper\src\PHPJasper.php:235 Stack trace: #0 C:\xampp\htdocs\html2\phpjasper-master\test.php(33): PHPJasper\PHPJasper->execute() #1 thrown in C:\xampp\htdocs\html2\phpjasper-master\vendor\geekcom\phpjasper\src\PHPJasper.php on line 235
Segui toda a documentação, videos e etc... Porém não tive êxito, alguém poderia dar um help?
Arquivo de teste SEM conexão com banco (RODANDO OK!)
<?php
require __DIR__ . '/vendor/autoload.php';
use PHPJasper\PHPJasper;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jrxml';
$output = __DIR__ . '/vendor/geekcom/phpjasper/examples';
$options = [
'format' => ['pdf', 'rtf']
];
$jasper = new PHPJasper;
$jasper->process(
$input,
$output,
$options
)->execute();
$filename = 'hello_world.pdf';
header('Content-Description: application/pdf');
header('Content-Type: application/pdf');
header('Content-Disposition:; filename=' . $filename);
readfile($output . '/' . $filename);
unlink($output . '/' . $filename);
flush();
?>Arquivo COM conexão com o banco (ERRO)
<?php
require __DIR__ . '/vendor/autoload.php';
use PHPJasper\PHPJasper;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/rel_cliente.jrxml';
$output = __DIR__ . '/vendor/geekcom/phpjasper/examples';
$options = [
'format' => ['pdf'],
'locale' => 'en',
'params' => [],
'db_connection' => [
'driver' => 'mysql', //mysql, ....
'username' => 'root',
'password' => '',
'host' => 'localhost',
'database' => 'grsystem',
'port' => '3306'
]
];
$jasper = new PHPJasper;
$jasper->process(
$input,
$output,
$options
)->execute();
$filename = 'hello_world.pdf';
header('Content-Description: application/pdf');
header('Content-Type: application/pdf');
header('Content-Disposition:; filename=' . $filename);
readfile($output . '/' . $filename);
unlink($output . '/' . $filename);
flush();
?>Gabriel Santos
Curtidas 0