phpjasper
phpjasper copied to clipboard
Bug when in the parameters values we have national characters.
When using national symbols in the parameters, phpjasper simply cuts them out. For example, Spanish characters: á, ó or í. This happens because when exec() is executed, the environment variable LANG is set with a different language. If in the execute() method, before executing the exec() command, add:
putenv('LANG=es_ES.UTF-8');
all characters are displayed correctly.
Maybe add a parameter to the configuration that would allow changing the environment variables before executing exec() command?
Hi @opxwebdev there is a parameter for this see the example below:
require __DIR__ . '/vendor/autoload.php';
use PHPJasper\PHPJasper;
$input = '/your_input_path/your_report.jasper';
$output = '/your_output_path';
$options = [
'format' => ['pdf'],
'locale' => 'en',
'params' => [],
'db_connection' => [
'driver' => 'postgres', //mysql, ....
'username' => 'DB_USERNAME',
'password' => 'DB_PASSWORD',
'host' => 'DB_HOST',
'database' => 'DB_DATABASE',
'port' => '5432'
]
];
$jasper = new PHPJasper;
$jasper->process(
$input,
$output,
$options
)->execute();
'locale' => 'en', for a complete list of locales see Supported Locales
Hi @geekcom I have this parameter set.
$options['locale'] = 'es_ES';
But the problem is that the exec() command cuts these characters.
And one more question. Do you take pull requests? I sent a pull request with a proposal to return the error text when a report generation error occurred. But the pull request is not accepted and there is no comment.
Hi @opxwebdev i need to check your PR
Olá @geekcom, estou com o mesmo problema na passagem de parâmetros. Quando tenho parâmetros com valores como ç é ó í estes caracteres estão sendo removidos no relatório gerado. Defini a opção 'locale' => 'pt_BR', porém mesmo assim o problema continuou.
Resolvi temporariamente adicionando um putenv('LANG=pt_BR.UTF-8'); antes do exec.
Hi @geekcom , I have the same problem and the parameter set too.
$options = [ 'format' => ['pdf'], 'locale' => 'pt_BR', // (...)
@opxwebdev 's solution solved the problem temporarily. 'thanks
Additional Information: In the Windows development environment (10 Pro, 1903, 18362.418), no problem. In the Debian Server 9.9 production environment, 'there are problems.
I tested several points to isolate the problem, settings in PHP and the OS itself... and it didn't work. The only thing that worked was the solution proposed here.
'thanks for listening