KoolReport's Forum

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

Blank PDF is generating while Export using koolreport in laravel #1731

Open Wasim opened this topic on on Nov 23, 2020 - 5 comments

Wasim commented on Nov 23, 2020

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.

Environment1: Windows Server IIS With PHP 7.2 Environment2: Linux centos Server With PHP 7.2

Both having same blank pdf upon export.

David Winterburn commented on Nov 24, 2020

Hi Wasim,

Please post your report's view and export php code for us to investigate it for you. Thanks!

Wasim commented on Nov 24, 2020

QuotationReport.view.php

<html>
<head>
    <title>hameer</title>
</head>
<body>
<p>hameer</p>
</body>
</html>

QuotationReportPdf.view.php

<html>
<head>
    <title>hameer</title>
</head>
<body>
<p>hameer</p>
</body>
</html>

export code

$quotationPdf = new QuotationReport(array("data"=>array($data)));

        //$quotationPdf = new QuotationReport();
        $quotationPdf->run()->export('QuotationReportPdf')
            ->pdf(array(
                "format"=>"A4",
                "orientation"=>"portrait",
                //"zoom"=>2
            ))
            ->toBrowser("quotation.pdf");

Quotation Class

<?php


namespace App\Services\CPM\ReportService;

use App\Services\App\ReportService;

class QuotationReport extends ReportService
{
    use \koolreport\export\Exportable;

    public function __construct($params = array())
    {
        parent::__construct($params);
    }

    public function settings()
    {
        return array(
            "dataSources"=>array(
            "all_data"=>array(
                "class"=>'\koolreport\datasources\ArrayDataSource',
                "data"=>$this->params["data"]
            )
        )
        );
    }

    public function setup()
    {
        $this->src('all_data')
            ->pipe($this->dataStore('quotation_data'));
    }
}

ReportService Class

<?php


namespace App\Services\App;


abstract class ReportService extends \koolreport\KoolReport
{
    use \koolreport\laravel\Friendship;
}

David Winterburn commented on Nov 24, 2020

Hi Wasim,

Please enable the following steps:

  1. Download Phantomjs binary file(depending on your operating system) to koolreport/export/bin folder

  2. Turn on PHP's display_errors and set error_reporting(E_ALL). This is the most important since we can not know what's wrong without any error message.

  3. Make sure that your PHP user has write permission for system temporary folder. Another option is to use a local temporary folder like this:

        $quotationPdf->run()->export('QuotationReportPdf')
        ->settings([
            'useLocalTempFolder' => true,
        ])
        ->pdf(...)
Wasim commented on Nov 24, 2020

while generating pdf it's pdf method which is creating/storing data in tmp file, but it is not writing data in pdf file that why we are getting blank file

David Winterburn commented on Nov 24, 2020

Hi Wasim,

Please download Phantomjs to your server at this location koolreport/export/bin and test its functionality with these standard examples:

https://phantomjs.org/screen-capture.html

Let us know if it could capture screens of webpage.

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

Laravel