Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erro ao gerar o relatório #288

Closed
Danillosdd opened this issue May 25, 2021 · 10 comments
Closed

erro ao gerar o relatório #288

Danillosdd opened this issue May 25, 2021 · 10 comments

Comments

@Danillosdd
Copy link

Ao chamar o arquivo relatorio.php?parametro=48 para gerar o pdf retornar no browser, o 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 /opt/NetMake/v9-php73/wwwroot/scriptcase/app/viniciuscontabilidade/relatorio/vendor/geekcom/phpjasper/src/PHPJasper.php:221 Stack trace: #0 /opt/NetMake/v9-php73/wwwroot/scriptcase/app/viniciuscontabilidade/relatorio/relatorio.php(63): PHPJasper\PHPJasper->execute() #1 {main} thrown in /opt/NetMake/v9-php73/wwwroot/scriptcase/app/viniciuscontabilidade/relatorio/vendor/geekcom/phpjasper/src/PHPJasper.php on line 221

@Danillosdd
Copy link
Author

Danillosdd commented May 25, 2021

meu arquivo relatório.php esta assim:




require __DIR__ . '/vendor/autoload.php';



use PHPJasper\PHPJasper;    

$parametro = $_GET['parametro'];

$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/relatorio.jrxml';   

$output = __DIR__ . '/vendor/geekcom/phpjasper/examples/relatorio-'.$parametro.'';



$options = [

    'format' => ['pdf'],

    'locale' => 'pt_BR',

    'params' => [

         'parametroprincipal' => $parametro,

    ],

    'db_connection' => [

        'driver' => 'postgres',

        'username' => 'postgres',

        'password' => '123456',

        'host' => 'localhost',

        'database' => 'teste',

        'port' => '5432'

    ]

];



$jasper = new PHPJasper;



$jasper->process(

        $input,

        $output,

        $options

)->execute
();



//	AQUI VOCÊ COLOCA O CÓDIGO PARA EXIBIR NO BROWSER.


$file = __DIR__ . '/vendor/geekcom/phpjasper/examples/relatorio-'.$parametro.'.pdf'; 


$filename = 'relatorio-'.$parametro.'.pdf'; /* Note: Always use .pdf at the end. */





header('Content-type: application/pdf');


header('Content-Disposition: inline; filename="' . $filename . '"');


header('Content-Transfer-Encoding: binary');


header('Content-Length: ' . filesize($file));


header('Accept-Ranges: bytes');



@readfile($file);



//	EXEMPLO EM PYTHON:

//		https://github.com/PyReportJasper/pyreportjasper#flask-example



?>```

@Danillosdd
Copy link
Author

Danillosdd commented May 25, 2021

Se eu executo no terminal o comando abaixo o pdf é gerado com sucesso, mais ao chamar pelo relatório.php no browser ocorre o erro mencionado.

./jasperstarter process "/relatorio/vendor/geekcom/phpjasper/examples/relatorio.jasper" -o "/relatorio/vendor/geekcom/phpjasper/examples" -f pdf

@Danillosdd
Copy link
Author

@jadsonbr

@jadsonbr
Copy link
Contributor

@Danillosdd
O erro informado geralmente é ocasionado pelo caminho do arquivo .jrxml inválido, como você pode ver aqui no código de validação da linha 221 da biblioteca

Provavelmente funcionou ao executar o básico pelo terminal por ter passado o caminho correto.
Verifique isso é nos dê um feedback.

@Danillosdd
Copy link
Author

Danillosdd commented May 28, 2021

@jadsonbr Verifiquei o caminho do input e esta correto, o arquivo do .jrxml esta neste diretório.

@Danillosdd
Copy link
Author

Danillosdd commented May 28, 2021

Creio que seja permissão, estou usando Ubuntu, e acho que dei permissão correto na pasta, pois dei um sudo chmod 777 -R na pasta do relatório

@jadsonbr
Copy link
Contributor

@Danillosdd qual versão da biblioteca está utilizando ?

@Danillosdd
Copy link
Author

@jadsonbr Aonde verifico esta informação?

@Danillosdd
Copy link
Author

Danillosdd commented May 31, 2021

Observação ao subir no xampp no windows da certo, o problema é no linux; por isso que eu acho que é problema de permissão

@Danillosdd
Copy link
Author

O Problema é o apache do scriptcase do meu ambiente de desenvolvimento, pois ao executar em outro apache gerou com sucesso; verifiquei os arquivos conf do apache do scriptcase e fiz a liberação do pgsql(Pois estou usando Postgres), e deu certo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants