cakephp - cakepdf dompdf notice undefined variable -


am trying generate pdf view using cakepdf not working expected.please bear me first time using plugin.

here set up

controller action

$this->pdfconfig = array(             'orientation' => 'portrait',             'filename' => $report['reg_no'],             'permissions' => array(                 'print','screen_readers','copy_contents'             )         );         $cakepdf = new cakepdf();  //create instance of cakepdf class         $cakepdf->template('pdf_view','default');  //define view use , optional layout          $pdf = $cakepdf->output();         $pdf = $cakepdf->write(app . 'webroot' .ds .'files'. ds . 'report.pdf');         //$this->set('tcpdf',$tcpdf);         $this->set('report',$report);         $this->render('/pdf/pdf_view'); 

my pdf_view.ctp has code: long

<style> tr .title {     font-weight: bold;     padding: 5px;     width:100px; } tr .text {     padding-left: 10px; } 

<div> <?php  if($report['school']['logo'] == null){echo  $this->html->image('/logo_small.png',array('width'=>'100px','height'=>'100px'));     }else {         echo $this->html->image($report['school']['logo'],array('width'=>'100px','height'=>'100px'));     } ?> <p>     <font size="5"><b><?php echo $report['school']['name']; ?></b></font><br />     <b><?php echo $report['school']['motto']; ?></b><br />     <b><?php echo $report['school']['address']; ?></b> </p> <p align="center"><b><font size="4">report card</font></b></p>  <div> <table align="left">     <tr>         <td class="title">admission_no</td>         <td class="text"><?php echo $report['reg_no']; ?></td>     </tr>     <tr>         <td class="title">form</td>         <td class="text"><?php echo $report['form']; ?></td>     </tr>     <tr>         <td class="title">position</td>         <td class="text"><?php echo $report['rank']; ?></td>     </tr> </table> </div> <div> <table align="left">     <tr>         <td class="title">name</td>         <td class="text"><?php echo $report['name']; ?></td>     </tr>     <tr>         <td class="title">stream</td>         <td class="text"><?php if($report['stream'] == null){             echo "<n/a>";             }else {                 echo $report['stream'];                 } ?></td>     </tr>     <tr>         <td class="title">out of</td>         <td class="text"><?php echo $report['outof']; ?></td>     </tr> </table> </div> <br /><br /> <div style="clear:left"><hr /> <!--<table>     <thead>         <tr>             <th>subject</th>             <th>score</th>             <th>grade</th>             <th>points</th>             <th>remarks</th>         </tr>     </thead>     <tbody>         <?php /*foreach ($report['subjects'] $key => $value): ?>         <tr>             <td><?php echo $key; ?></td>             <td><?php echo $value['score']; ?></td>             <td><?php echo $value['grade']; ?></td>             <td><?php echo $value['points']; ?></td>         </tr>         <?php              $totpoints += $value['points'];             endforeach; ?>         <tr>             <td>total</td>             <td><?php echo $report['total']; ?></td>             <td><?php echo $totpoints;*/ ?></td>         </tr>        </tbody> </table>--> </div> <br /><hr /><br /> <p>     <font size="4"><b>class teacher remarks</b></font><br /><br />     <font size="4"><b>principal remarks</b></font><br /><br />     <font size="4"><b>fees balance</b></font><br />     <font size="4"><b>closing date</b></font>     <font size="4"><b>opening date</b></font> </p> 

problems:

1.the inline styles table not applied.

2.the generated pdf full of notices undefined variable: report in pdf_view.ctp(yet used

$this->set('report',$report)  

in controller action)

  1. my image not displayed in pdf after setting in dompdf_config.inc.php

    define("dompdf_enable_remote", true);

4.about commented out tbody tag..if uncomment error

error: call undefined method domtext::getattribute()  file: /home/r2d2/web-php/sms/app/plugin/cakepdf/vendor/dompdf/include  /cellmap.cls.php  line: 400 

question: why getting undefinde variable report,image not loading,styles not applying , #4 above..

managed solve issues.may of first time plugin user:

1.realized cannot pass variable pdf rendering views.instead following other answers here on stackoverflow:this worked

$this->viewvars(array("report",$report)); 

2.images::solved adding fullbase array options:

echo $this->html->image($report['school']['logo'],array('width'=>'100px','height'=>'100px','fullbase'=>true)); 

3.removed tbody tag.turned out documentation of css styles not supported


Comments