KoolReport's Forum

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

Laravel Koolreport and Export PDF always return empty pdf #1086

Open AST opened this topic on on Sep 16, 2019 - 7 comments

AST commented on Sep 16, 2019

Hello,

I know there are some issues related to this empty pdf issue, but no solution works for me yet. Also have tried the sample given in the documentation and still no luck.

Environment: Windows 10 XAMPP PHP 7

Below are my codes:

SalesReport.php

<?php

namespace App\Reports;

use koolreport\KoolReport;
use koolreport\export\Exportable;
use koolreport\laravel\Friendship;

class SalesReport extends KoolReport
{
    use Friendship, Exportable;

    function setup()
    {
        $this->src("mysql")
            ->query("SELECT * FROM items")
            ->pipe($this->dataStore("items"));
    }
}

SalesReport.view.php

<?php

use \koolreport\widgets\koolphp\Table;
?>

<html>

<body>
    <h1>It works</h1>
    <?php
    Table::create([
        "dataSource" => $this->dataStore("items")
    ]);
    ?>
</body>

</html>

SalesReportController

<?php

namespace App\Http\Controllers\Report;

use App\Http\Controllers\Controller;
use App\Reports\SalesReport;

class SalesReportController extends Controller
{
    public function index()
    {
        $report = new SalesReport();
        $report->run()->export()->pdf(array(
                "format" => "A4",
                "orientation" => "portrait"
            ))->toBrowser("salesreport.pdf", true);
    }
}

Thanks.

KoolReport commented on Sep 16, 2019

Hi AST,

So you have download the phantomjs.exe and put it to "koolreport/export/bin" folder, haven't you? And please make sure the phantomjs.exe has permission to execute.

AST commented on Sep 17, 2019

Yes, I have downloaded phantomjs and tried phantomjs getting started by using cmd.

How can I check if the permission for phantomjs.exe is correct for laravel in windows 10?

KoolReport commented on Sep 17, 2019

Let try to remove the Table for now, we try to print out the pdf first. So please let me know if your url look like this http://localhost/... or look like this http://localhost:8000/.... Does it has the port on it?

AST commented on Sep 17, 2019

It has port behind the url http://localhost:8000/...

KoolReport commented on Sep 17, 2019

I see, I asked because there is an known issue of export package with the port currently. Although it has been solved but we have not released yet. Could you please try with normal XAMPP hosting at 80 port rather than using php hosting by the laravel ( using command php -S locahost:8000 ...). Please let me know if it works.

For above issue, we will have new release soon.

AST commented on Sep 17, 2019

Nice, I tried it and it works!

Thank you very much.

Note: maybe for anyone who also faced this issue, I followed this link and setup laravel with XAMPP (https://www.5balloons.info/install-laravel-5-7-xampp-windows/)

KoolReport commented on Sep 17, 2019

Great! Thank for your sharing :)

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