Hello I'm trying to export pdf, but it returns me blank pdf if there is any Table or chart used inside the view.php file. If i'm trying with simple html then it will output that content in PDF. I have also make use of use \koolreport\export\Exportable; package.
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),
);
?>
<html>
<head>
<title>Content that you want to convert to PDF</title>
</head>
<body>
<style>
h1 {color:red}
</style>
<h1>PDF</h1>
<h1>Column chart div</h1>
<?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"=>"$"),
)
));
?>
<body>
</html>
this is my report.blade.php
<?php echo $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");
}
}
I got stuck on the problem. Please help. Regards