KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Export pdf Laravel #2604

Closed Javier Córdova opened this topic on on Mar 4, 2022 - 5 comments

Javier Córdova commented on Mar 4, 2022

Hi Sebastian, I have tried to save the generated report from Laravel, but I keep getting Undefined array key "REQUEST_URI" error, I attach my code:

$report = new AtencionGeneralReport($data_report);
                $filename = storage_path('app\public\pdf\reporte_'.$datos->nombre.'.pdf');  
                FacadesLog::info('Reporte ATC instanciado. ' . $filename);
                $report->run()
                    ->export("AtencionGeneral")
                    ->settings([
                        "useLocalTempFolder"=>true
                    ])
                    ->pdf(array(
                        "format"=>"A4",
                        "orientation"=>"portrait",
                        //"zoom"=>2
                    ))
                    ->saveAs($filename);

I read a previous post where it is mentioned that the problem is the route, but it still generates that error, I hope you can please help me.

KoolReport commented on Mar 7, 2022

Could you please give us the screenshot of the error.

Javier Córdova commented on Mar 7, 2022

Yes, sure

Sebastian Morales commented on Mar 8, 2022

Pls check my answer here:

Unable to save pdf using Laravel scheduler

Newton commented on Mar 8, 2022

@Javier, I had the same problem to use a generated PDF report.And the solution is relatively simple:

1 - Transform your route in a API route, using a API group and, ifi you are following Laravel standards, put this route inside routes/api.php;

2 - On your scheduler invoke this route like this example: $response = Illuminate\Support\Facades\Http::get('http://exemple.com/api/<route-name>?<params-if-you-have-some>')

3 - All kinds of Laravel stuff and Koolreport will work. Use Storage::disk('xxxx') to save your files on desired storage, if you wanto to do so.

Javier Córdova commented on Mar 8, 2022

Thank you very much for your suggestion @Newton, I tell you that I already did that, I generate and save the report from api, since if you call Koolreport from a Web server, that apparently caused the error. In this way, it works correctly.

Thanks again for your response.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

Laravel