KoolReport's Forum

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

I use this export in Laravel,while use the css link like the 'bootstrap.min.css' in the 'view.php', export to pdf is the blank. #492

Open wangjunjie opened this topic on on Oct 10, 2018 - 8 comments

wangjunjie commented on Oct 10, 2018
<html>
<body style="margin:0.5in 1in 0.5in 1in">
<link rel="stylesheet" href="/packages/koolReport/assets/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/packages/koolReport/assets/bootstrap/css/bootstrap-theme.min.css"/>

If do not use this link ,the later html tags can be converted to pdf , is not blank。 And how can i use the link tag rightly? thanks for help!

KoolReport commented on Oct 10, 2018

Could you please try to create the <head></head> tags above the body and add the link there. Let me know if it works. Please make sure that the links are all correct.

wangjunjie commented on Oct 10, 2018

More than this ,while using the table or the Chart in the export view, the result is blank also.

wangjunjie commented on Oct 10, 2018

Thank you so much for your reply@koolreport, but it's not work, and i am sure the link road is correct, by the way, even if the link is not correct, i think the pdf shouldn't be blank ,em.. so if , is there any other configuration i make mistake?

KoolReport commented on Oct 10, 2018

Could you please show me your code

wangjunjie commented on Oct 10, 2018

MyReport1.view.php

<?php
use \koolreport\widgets\koolphp\Table;
?>
<html>
<body style="margin:0.5in 1in 0.5in 1in">
<head>
<link rel="stylesheet" href="/packages/koolReport/assets/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/packages/koolReport/assets/bootstrap/css/bootstrap-theme.min.css"/>
</head>
<hr/>
<div class="text-center">
    <h2>消防设备巡检结果</h2>
    <h5>任务名称:<?php echo "test1"; ?></h5>
</div>
<hr/>
<?php
Table::create(array(
    //datastore与MyReport.php中同参数
    "dataStore" => $this->dataStore('respect_report'),
    "columns" => array(

        "device_name" => array(
            "type" => "string",
            "label" => "设备名称",
        ),
        "address" => array(
            "label" => "地址"
        ),
        "check_items" => array(
            "type" => "string",
            "label" => "检查项"
        ),
        "is_qualified" => array(
            "type" => "string",
            "label" => "状态",
            "formatValue" => function ($value) {
                return $value;
            },
        ),
        "person_in_charge" => array(
            "type" => "string",
            "label" => "责任者"
        ),
        "content" => array(
            "type" => "string",
            "label" => "巡检记录"
        ),
    ),
    "cssClass" => array(
        "table" => "table table-hover table-bordered"
    )
))
 ?>
</body> </html>

function in my controller:

 public function export()
    {
        $report=new MyReport();
        session_start();
        $report->run()->export('MyReport1')->pdf(array(
            "format"=>"A4",
            "orientation"=>"portrait"
        ))->toBrowser("myreport.pdf");

MyReport.php

namespace App\Reports;
use \koolreport\KoolReport;

class MyReport extends KoolReport
{
    use \koolreport\laravel\Friendship;
    use \koolreport\export\Exportable;
    
    function settings()
    {
        return array(
            "assets"=>array("path"=>"../../public/packages/koolReport/assets",
                "url"=>"/packages/koolReport/assets"),
            "dataSources"=>array(
                "report"=>array(
                    'host' => '127.0.0.1',
                    'username' => 'root',
                    'password' => 'root',
                    'dbname' => 'sucg_fp',
                    'charset' => 'utf8',
                    'class' => "\koolreport\datasources\MySQLDataSource"
                ),
            )
        );
    }

    public function setup(){
        $this->src('report')->query("SELECT * FROM tableContents")
            ->pipe($this->dataStore('respect_report'));

        $this->src('report')->query("SELECT * FROM device_classfy_count")
            ->pipe($this->dataStore('pie_report'));
    }
}
wangjunjie commented on Oct 10, 2018

Oh, I am not sure if it is the reason that i lose the blade.php? And if this cause my problem ,how could i resolve this on laravel when i do export? I have tried many method to add the blade ,but it did not work. Or, May be is so bold to ask if there is not much waste of your time, could you please to make a guide about doing export on laravel...,i find no way to out... Thanks a lot, regards!

KoolReport commented on Oct 11, 2018

Let do this:

  1. Remove the <link> tag
  2. In your report, you add this
class MyReport extends \koolreport\KoolReport
{
    use \koolreport\clients\Bootstrap; // Add this line
}

Let me know if it works.

wangjunjie commented on Oct 11, 2018

No, it's not work. I am not sure if is the link problem. Beacause when i use the tablechart in the pdfview without using link ,the pdf alse be blank. However, if only use the normal tag, without both of above, even i use the style tag to replace link css, result pdf could be normal.

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