Fórum PHPJasper (Gerar relatorio, comunicação com o banco) #607744
26/01/2020
0
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!)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <?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)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | <?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
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)