KoolReport's Forum

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

SaveAs() doesn't save my report #894

Closed Nuvap SRL opened this topic on on May 28, 2019 - 1 comments

Nuvap SRL commented on May 28, 2019

Hello, I'm trying to save my report into a folder by using the saveAs() function provided by the Export package. The report is also sent to browser with toBrowser() (and this works). My code is the following:

ob_end_clean();
$report = new PdfPaging();
$report->run();
$report->export()
->settings(array(
    "phantomjs" => "/usr/bin/phantomjs",
    "resourceWaiting"=>2000
))
->pdf([
    "format" => "A4",
    "margin" => [
        'top'=> '50px',
        'right'=> '20px',
        'bottom'=> '5px',
        'left'=>'20px'
    ]
])
->toBrowser($filename);

$report->export()
->settings(array(
    "phantomjs" => "/usr/bin/phantomjs",
    "resourceWaiting"=>2000
))
->pdf([
    "format" => "A4",
    "margin" => [
        'top'=> '50px',
        'right'=> '20px',
        'bottom'=> '5px',
        'left'=>'20px'
    ]
])
->saveAs($filePath);

The variable $filePath is a valid absolute path, but I also tried with a relative path with no success. Am I missing something? Thank you.

Nuvap SRL commented on May 28, 2019

Solved the problem. After calling toBrowser() the script actually returned, so it didn't execute the commands below. Saving the pdf first was the correct way.

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
help needed
solved

Export