KoolReport's Forum

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

Export PDF Is Blank #495

Open Hoang Nguyen opened this topic on on Oct 15, 2018 - 15 comments

Hoang Nguyen commented on Oct 15, 2018

Hi TeamSupport, I have an issue when I export pdf, my file pdf is blank even I tried a lot of ways in laravel.

index.php

$report->run()->export()->pdf(array(
                "format"=>"A4",
                "orientation"=>"portrait"
            ))->toBrowser($fileName);

PDFClient.php

use \koolreport\export\Exportable;
    
    function setup()
    {
        try
        {
            $query = $this->src('mysql')->query("{$this->query}");
            $query->pipe($this->dataStore('PDFClientReport'));
        } catch (\Exception $e)
        {
            error_log($e->getMessage(), $e->getCode());
        }
    }

PDFClient.view.php

<!-- PDFClient.view.php -->
<?php
    use \koolreport\widgets\koolphp\Table;
?>
<!DOCTYPE html>
<html>

<body>
    <div class="container">
        <div class="text-center">
            <h1 style="color: red;">Cash In Report</h1>
            <h4 id="new">This report show the cash-in report per month</h4>
        </div>
        <hr/>
        <?php
            Table::create(array(
                "dataStore"=>$this->dataStore('PDFClientReport'),
                "columns"=>array(
                    "Campaign",
                    "Date",
                    "Status",
                    "Quotes",
                    "TOTAL PRICE"
                ),
            ));
        ?>
    </div>

</body>

</html>

HTML is oke, but wrong at Table, I try dump html have data but pdf is blank.

Thanks Regards,

KoolReport commented on Oct 15, 2018

Do you mean that if the page has no widget like Table, only HTML then pdf is generated without any issue but if the page has widget like Table containing data, the page will return blank?

Hoang Nguyen commented on Oct 15, 2018

Hi support team, I found an error, I followed the instructions and used the table library above. But it doesn't generate script Jquery and CSS file. I try to integrate link static table.js and Jquery but pdf => blank.

Let me know how to fix it. Thanks

KoolReport commented on Oct 16, 2018

Could you please following this topic to set the url and path for asset folder. This will allow KoolReport to copy inaccessible resource to public place. You are using Laravel so you may pointing the url and path to the public folder ( or assets folder within public).

Hoang Nguyen commented on Oct 16, 2018

I did it but pdf it not work !

KoolReport commented on Oct 16, 2018

I will tell dev.team to make example in Laravel for you.

Mazmur commented on Oct 30, 2018

Dear Koolreport,

I have a same trouble.... my table is blank on export to pdf file. (Create in Codeigniter).

From here :

I call Downlod PDF with here :

         require APPPATH."/reports/production/MyReport3.php";
	
	$report = new MyReport3();
	$report->run()
	->export('MyReport3Pdf')
	->pdf(array(
		"format"=>"A4",
		"orientation"=>"portrait",
		//"zoom"=>2
	))
	->toBrowser("produksi_report.pdf");

Help me Please.

KoolReport commented on Oct 30, 2018

It seems to me that your table has no data. May be the report has some parameters which is used for SQL Query. But those parameters is not posted to server and as the result the table is blank.

Mazmur commented on Oct 30, 2018

Yes in Myreport3.view.php I have a date parameter. How do I retrieve the date parameter in Myreport3.view.php and enter it into Myreport3Pdf.view.php?

Mazmur commented on Oct 31, 2018

Dear Koolreport,

My export PDF with some parameter running well.

Thank you

KoolReport commented on Oct 31, 2018

Awesome

lori commented on Dec 9, 2018

Hi . l when export to pdf in larave, my file pdf is blank .

// web.php Route::get('admin/testreport', "TestReportController@index");

// MyPage.php <?php namespace App\Reports; class MyPage extends \koolreport\KoolReport {

use \koolreport\laravel\Friendship;
use \koolreport\export\Exportable;
public function settings()
{   }   
protected function setup()
{    } 

}

// MyPage.view.php <html>

<head>
    <title>Content that you want to convert to PDF</title>
</head>
<body>
    <h1>Export HTML to PDF</h1>
    <p>It is easy to convert HTML to PDF using KoolReport's Export package</p>
</body>

</html>

// MyPageController.php <?php namespace App\Http\Controllers; use App\Reports\MyPage; class MyPageController extends Controller {

public function index()
{
    $report = new MyPage;
    $report->run()->export('MyPage')
        ->settings(array(
            "resourceWaiting"=>5000,
        ))
        ->pdf(array(
            "format"=>"A4",
            "orientation"=>"portrait"
        ))
        ->toBrowser("mypage.pdf",true);
}

}

help me. thanks.

Mario commented on Aug 27, 2019

when export to pdf in laravel, generate the pdf file empty

KoolReport commented on Aug 28, 2019

Please make sure that the server does echo any content before the toBrowser() function is called, any header content as well because those contents will contaminate the pdf file.

Letzer Cartagena commented on Oct 11, 2019

Laravel generate empty PDF, support!

KoolReport commented on Oct 12, 2019

Please make sure that:

  1. Choose correct phantomjs version for your OS
  2. Download and save to koolreport\export\bin folder
  3. Make sure the phantomjs execution file has permission to run, recommended 755

Let me know if it works.

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

Export