KoolReport's Forum

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

Getting blank PDF no matter what #685

Closed gkurl opened this topic on on Feb 18, 2019 - 13 comments

gkurl commented on Feb 18, 2019

Hi Guys,

I am trying to run this template:

<?php
                 use \koolreport\widgets\koolphp\Table;
				 use \koolreport\widgets\google\PieChart;
				 use \koolreport\widgets\google\BarChart;
                 use \koolreport\widgets\google\ColumnChart;
                 use \koolreport\export\Exportable;

                 ?>
                 <html>
                 <head>
                     <meta charset="utf-8" />
                     <meta http-equiv="X-UA-Compatible" content="IE=edge">
                     <title>Hours of Care</title>
                     <meta name="viewport" content="width=device-width, initial-scale=1">
                 </head>
                 <body>
                 <h1 class ="title"> Hours of Care </h1></br></br>
                 <img src = "./menulogob@3x.png" class = "logo img-responsive" width = "300px" height = "300px">
                 <div class = "container-fluid">
                  <style> 
                 
                 body {       
                 
                    font-family: 'Raleway', sans-serif;
                 }
                 
                .title {
                text-align: center;
                font-weight: bold;
                }
                
                .table row-group:first-child .table tr:last-child {
                position: absolute;
                right: 0;
                }
                
              /*  .tablecustom td:nth-child(1) {
                    
                    background-color:#3A6BB4;
                     font-weight: bold;
                     color: white;      
                    
                }   */
                
                /*  .tablecustom th {
                
                    background-color:#3A6BB4;
                 font-weight: bold;
                 color: white;     
                 
                 } */
                 
                .grid {
                display: contents;
                width: 100%;
                }
                
                .totalcell {
                background: #275DAD;
                color: white;
                }
                
                .logo { 
                 
                 position: absolute;
                 left:0;
                 top:0; 
                max-width: 70%; 
                height: auto; 
                padding: 20px 20px;
                 }
                
                </style>

                     <?php
                  Table::create([
                    "dataStore" => $this -> dataStore('resultset1'),
                     "columns" => ["code" => ["label" => "Code"], "fullname" => ["label" => "Name"], "AssignmentDate" => ["label" => "Assignment date"], 
                     "SUMScheduledMinute" => ["label" => "Scheduled Time"], "SUMActualMinute" => ["label" => "Actual Time"]],
                    "cssClass" => ["table"=>"tablecustom table table-bordered table-striped table-hover table-condensed"],
                    "grouping" => [
                    "JobroleCode" =>["calculate" => [
                    "{sumSchedMin}" => ["sum", "SUMScheduledMinute"],
                    "{sumActualMin}" => ["sum", "SUMActualMinute"]], 
                     "top" => "<b>Jobrole: </b>{JobroleCode}", 
                    "bottom" => "<td></td><td></td> <td class = 'totalcell'><b> Total </b></td><td><b> {sumSchedMin} </b></td></br> </br><td><b> {sumActualMin} </b></td>"]]
                    ]);
                    ?>

via export but always get blank PDF - I am calling it like so:

  $reporthtml = $maxkool -> run() -> render(null, true);
  $maxkool -> run() -> export($reporthtml) -> pdf([
                        "format"=>"A4",
                        "orientation"=>"portrait"]) -> toBrowser("maxtimereport.pdf");

So returning the above template and passing it into export function - always gives me blank PDF.

I have included

    use \koolreport\export\Exportable;

Inside my report class and ensured that the phantomjs file in the bin directory is compatible with my server (CentOS so using Linux version) and has permissions to read write and execute.

Please any indications as to why this isn't working?

gkurl commented on Feb 18, 2019

If I do a file_put_contents on the $reporthtml just after it has rendered and open the test html file I can see that the report/table has rendered and is displaying correctly on page - but it isn't when placing that exact same code into export() function

gkurl commented on Feb 18, 2019

This is report code directly after render function has been executed: - please tell me if anything is wrong here?

                 <html>
                 <head>
                     <meta charset="utf-8" />
                     <meta http-equiv="X-UA-Compatible" content="IE=edge">
                     <title>Hours of Care</title>
                     <meta name="viewport" content="width=device-width, initial-scale=1">
                 </head>
                 <body><script type='text/javascript' src='/koolreport/src/clients/core/KoolReport.js'></script><script type='text/javascript'>KoolReport.load.resources({"js":["\/koolreport\/src\/clients\/jquery\/jquery.min.js",["\/koolreport\/src\/clients\/bootstrap\/js\/bootstrap.min.js"]],"css":["\/koolreport\/src\/clients\/bootstrap\/css\/bootstrap.min.css","\/koolreport\/src\/clients\/bootstrap\/css\/bootstrap-theme.min.css"]});</script>
                 <h1 class ="title"> Hours of Care </h1></br></br>
                 <img src = "./menulogob@3x.png" class = "logo img-responsive" width = "300px" height = "300px">
                 <div class = "container-fluid">
                  <style> 
                 
                 body {       
                 
                    font-family: 'Raleway', sans-serif;
                 }
                 
                .title {
                text-align: center;
                font-weight: bold;
                }
                
                .table row-group:first-child .table tr:last-child {
                position: absolute;
                right: 0;
                }
                
              /*  .tablecustom td:nth-child(1) {
                    
                    background-color:#3A6BB4;
                     font-weight: bold;
                     color: white;      
                    
                }   */
                
                /*  .tablecustom th {
                
                    background-color:#3A6BB4;
                 font-weight: bold;
                 color: white;     
                 
                 } */
                 
                .grid {
                display: contents;
                width: 100%;
                }
                
                .totalcell {
                background: #275DAD;
                color: white;
                }
                
                .logo { 
                 
                 position: absolute;
                 left:0;
                 top:0; 
                max-width: 70%; 
                height: auto; 
                padding: 20px 20px;
                 }
                
                </style>

                     <krwidget widget-name='ktable5c6a9f258da601' widget-type='koolreport/widgets/koolphp/Table'><div class="koolphp-table " id="ktable5c6a9f258da601">
    <table class='table tablecustom table table-bordered table-striped table-hover table-condensed'>
                <thead>
                        <tr>
            <th>Code</th><th>Name</th><th>Assignment date</th><th>Scheduled Time</th><th>Actual Time</th>            </tr>
        </thead>
                        <tbody>
            <tr from='0' to='5' class='row-group' ><td colspan='5'><b>Jobrole: </b>APPRENT</td></tr>            <tr ri='0'>
                                        <td rv="879"  >
                            879                        </td>
                                            <td rv="Noah Leaf"  >
                            Noah Leaf                        </td>
                                            <td rv="2018-01-22"  >
                            2018-01-22                        </td>
                                            <td rv="1"  >
                            1                        </td>
                                            <td rv="1"  >
                            1                        </td>
                                </tr>
                        <tr ri='1'>
                                        <td rv="878"  >
                            878                        </td>
                                            <td rv="Sarah Jones"  >
                            Sarah Jones                        </td>
                                            <td rv="2018-01-28"  >
                            2018-01-28                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="0"  >
                            0                        </td>
                                </tr>
                        <tr ri='2'>
                                        <td rv="877"  >
                            877                        </td>
                                            <td rv="Tim Smith"  >
                            Tim Smith                        </td>
                                            <td rv="2018-01-29"  >
                            2018-01-29                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                </tr>
                        <tr ri='3'>
                                        <td rv="876"  >
                            876                        </td>
                                            <td rv="Billy Jackson"  >
                            Billy Jackson                        </td>
                                            <td rv="2018-01-08"  >
                            2018-01-08                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="7"  >
                            7                        </td>
                                </tr>
                        <tr ri='4'>
                                        <td rv="893"  >
                            893                        </td>
                                            <td rv="Test B"  >
                            Test B                        </td>
                                            <td rv="2018-02-07"  >
                            2018-02-07                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                </tr>
            <tr from='0' to='5' class='row-group' ><td></td><td></td> <td class = 'totalcell'><b> Total </b></td><td><b> 33 </b></td></br> </br><td><b> 24 </b></td></tr><tr from='5' to='13' class='row-group' ><td colspan='5'><b>Jobrole: </b>CARER</td></tr>            <tr ri='5'>
                                        <td rv="881"  >
                            881                        </td>
                                            <td rv="Ian Peele"  >
                            Ian Peele                        </td>
                                            <td rv="2018-01-15"  >
                            2018-01-15                        </td>
                                            <td rv="1"  >
                            1                        </td>
                                            <td rv="1"  >
                            1                        </td>
                                </tr>
                        <tr ri='6'>
                                        <td rv="882"  >
                            882                        </td>
                                            <td rv="James McDermot"  >
                            James McDermot                        </td>
                                            <td rv="2018-01-15"  >
                            2018-01-15                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                </tr>
                        <tr ri='7'>
                                        <td rv="880"  >
                            880                        </td>
                                            <td rv="Scarlet Tin"  >
                            Scarlet Tin                        </td>
                                            <td rv="2018-01-18"  >
                            2018-01-18                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                </tr>
                        <tr ri='8'>
                                        <td rv="883"  >
                            883                        </td>
                                            <td rv="Tonya Uri"  >
                            Tonya Uri                        </td>
                                            <td rv="2018-01-29"  >
                            2018-01-29                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                </tr>
                        <tr ri='9'>
                                        <td rv="888"  >
                            888                        </td>
                                            <td rv="Mary Balingoiwez"  >
                            Mary Balingoiwez                        </td>
                                            <td rv="2018-08-31"  >
                            2018-08-31                        </td>
                                            <td rv="10"  >
                            10                        </td>
                                            <td rv="10"  >
                            10                        </td>
                                </tr>
                        <tr ri='10'>
                                        <td rv="902"  >
                            902                        </td>
                                            <td rv="Greg James"  >
                            Greg James                        </td>
                                            <td rv="2018-03-06"  >
                            2018-03-06                        </td>
                                            <td rv="1"  >
                            1                        </td>
                                            <td rv="1"  >
                            1                        </td>
                                </tr>
                        <tr ri='11'>
                                        <td rv="904"  >
                            904                        </td>
                                            <td rv="Chad Lowe"  >
                            Chad Lowe                        </td>
                                            <td rv="2018-08-21"  >
                            2018-08-21                        </td>
                                            <td rv="10"  >
                            10                        </td>
                                            <td rv="0"  >
                            0                        </td>
                                </tr>
                        <tr ri='12'>
                                        <td rv="903"  >
                            903                        </td>
                                            <td rv="Max Thyme"  >
                            Max Thyme                        </td>
                                            <td rv="2018-09-03"  >
                            2018-09-03                        </td>
                                            <td rv="10"  >
                            10                        </td>
                                            <td rv="10"  >
                            10                        </td>
                                </tr>
            <tr from='5' to='13' class='row-group' ><td></td><td></td> <td class = 'totalcell'><b> Total </b></td><td><b> 56 </b></td></br> </br><td><b> 46 </b></td></tr><tr from='13' to='15' class='row-group' ><td colspan='5'><b>Jobrole: </b>CLEANER</td></tr>            <tr ri='13'>
                                        <td rv="900"  >
                            900                        </td>
                                            <td rv="Stuart Nicholson"  >
                            Stuart Nicholson                        </td>
                                            <td rv="2018-02-26"  >
                            2018-02-26                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="0"  >
                            0                        </td>
                                </tr>
                        <tr ri='14'>
                                        <td rv="901"  >
                            901                        </td>
                                            <td rv="Louise Smith"  >
                            Louise Smith                        </td>
                                            <td rv="2018-01-22"  >
                            2018-01-22                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                            <td rv="8"  >
                            8                        </td>
                                </tr>
                        <tr from='13' to='15' class='row-group' ><td></td><td></td> <td class = 'totalcell'><b> Total </b></td><td><b> 16 </b></td></br> </br><td><b> 8 </b></td></tr>        </tbody>
    </table>
    </div>
<script type="text/javascript">
KoolReport.widget.init({"js":["\/koolreport\/src\/clients\/jquery\/jquery.min.js",["\/koolreport\/src\/widgets\/koolphp\/table\/table.js"]],"css":["\/koolreport\/src\/widgets\/koolphp\/table\/table.css"]},function(){
    ktable5c6a9f258da601 = new KoolReport.koolphp.table('ktable5c6a9f258da601',{"cKeys":["code","fullname","AssignmentDate","SUMScheduledMinute","SUMActualMinute"],"removeDuplicate":[],"paging":null});
        });
</script></krwidget>
KoolReport commented on Feb 18, 2019

If you export pdf and send to browser with toBrowser() function, you should remove the report render() function. It is because both html and pdf content is sent to browser and cause confuse. So you need to run report and then do export.

gkurl commented on Feb 18, 2019

Could you please explain further? I understand what you are saying, but if I don't render() the report then I have no code to send into the export() function? I have tried saveAs() method also and tried running it that way but still blank PDF.

KoolReport commented on Feb 18, 2019

We normally make two seperate file, the index.php will run and render report, then we may do post or get to another file export.php in which we use export toBrowser().

KoolReport commented on Feb 18, 2019

We normally make two seperate file, the index.php will run and render report, then we may do post or get to another file export.php in which we use export toBrowser().

gkurl commented on Feb 18, 2019

Ok I understand, but the principle is the same, instead of rendering and output to a separate file, I am rendering and output to a variable and passing that in export() so I am not sure how or why it would not show in PDF?

KoolReport commented on Feb 18, 2019

In this new version, we have new package called CloudExport, do you want to try. Let see if it can work.

gkurl commented on Feb 18, 2019

Ok yes, I am willing to try - please guide :)

KoolReport commented on Feb 18, 2019

Please follow our guide here. Please let us know if you need any assistance.

gkurl commented on Feb 18, 2019

Ok thank you for your help - if I run across any problems - shall I post in here or create new topic?

KoolReport commented on Feb 18, 2019

You create another topic, better in the way that one issue one topic :)

gkurl commented on Feb 18, 2019

Ok thank you - I have followed instructions if I come across any issues I will let you know.

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
None yet

Export