KoolReport's Forum

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

Phantom js error #414

Open Sunil Kumar opened this topic on on Aug 14, 2018 - 4 comments

Sunil Kumar commented on Aug 14, 2018

Hello,

I have integrated koolreport with laravel . When I try to export pdf with simple html css content it is working fine. but when I added any of Barchart or Table then it returns a blank pdf. I also tried by adding assets key to setting function but vain. I have tried all possiblities but nothing worked. After that I create a folder inside the public folder and put vendor folder there along with all files needed to create pdf. Everything works fine. Now, when i tried to access report.php inside public folder it give me an error of could not execute phantom js. But if i place it outside the public folder it works fine and output pdf along with charts. Please help me to resolve this issue.

Regards

KoolReport commented on Aug 16, 2018

Could you please describe your folder structure, your file and some of the important code

Sunil Kumar commented on Aug 16, 2018

Hello

According to laravel koolreport, I have placed my reports folder inside the app folder. Created a new ReportController. Also a report.blade.php inside the views. Everything is working fine. But only with html and css . When there is only html it output the pdf content. But when i tried to add code for table or Barchart it return me a blank pdf. Exportable package is also there. Also made use of assets inside setting function but nothing works.

Here is my code

This is my MyReport.view.php file

<?php 
use \koolreport\widgets\google\BarChart;
$category_amount = array(
        array("category"=>"Books","sale"=>32000,"cost"=>20000,"profit"=>12000),
        array("category"=>"Accessories","sale"=>43000,"cost"=>36000,"profit"=>7000),
        array("category"=>"Phones","sale"=>54000,"cost"=>39000,"profit"=>15000),
        array("category"=>"Movies","sale"=>23000,"cost"=>18000,"profit"=>5000),
        array("category"=>"Others","sale"=>12000,"cost"=>6000,"profit"=>6000),
    );
?>

Code for bar chart

       <?php
                BarChart::create(array(
                    "title"=>"Sale Report",
                    "dataStore"=>$category_amount,
                    "columns"=>array(
                        "category"=>array("label"=>"category"),
                        "sale"=>array("label"=>"Sale","type"=>"number","prefix"=>"$"),
                        "cost"=>array("label"=>"Cost","type"=>"number","prefix"=>"$"),
                        "profit"=>array("label"=>"Profit","type"=>"number","prefix"=>"$"),
                    )
                ));
            ?>

This is my report.blade.php

<?php
   $report->render();
?>

And this is my ReportController.php

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Reports\MyReport;
use View;
use \koolreport\instant\Widget;
use \koolreport\chartjs\ColumnChart;

class ReportController extends Controller{
  
public function __construct(){
        $this->middleware("guest");
    }
  
public function index(Request $request){
     $report = new MyReport();
        $report->export()
        ->settings(array(
            "resourceWaiting"=>5000,
        ))
        ->pdf(array(
            "format"=>"A4",
            "orientation"=>"portrait"
        ))
        ->toBrowser("report.pdf");
       

    }
    
}
KoolReport commented on Aug 16, 2018

In MyReport.php, could you please add:

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\laravel\Friendship;
    ...
}

Let see if it works.

Sunil Kumar commented on Aug 16, 2018

Yes I have also tried with this

class MyReport extends \koolreport\KoolReport {

use \koolreport\laravel\Friendship;
...

}

but still not working.

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

None