wkhtmltopdf - mikehaertl/phpwkhtmltopdf wrapper - Works when running PHP file from command line -


i have made following file:

test.php

<?php  require 'vendor/autoload.php'; use mikehaertl\wkhtmlto\pdf;  $htmlstring = <<<eot <!doctype html>     test </html>     eot;  $pdf = new pdf($htmlstring); $pdf->setoptions(array(     'orientation' => 'landscape' ));  $pdf->saveas('new.pdf');  ?> 

when run command line (ubuntu 12.x):

sudo php test.php 

i file shows in directory , works intended. take following file trying apply above real world scenario - note: when echo $htmlstring valid , expected string.

testpdf.php

<?php     // start session , check if user logged in     session_start();     if(!isset($_session['permission']))     {         die('please login.');     }     // dependencies     require 'vendor/autoload.php';     use mikehaertl\wkhtmlto\pdf;     require 'database.php';     // initialize     $client = $db->real_escape_string($_get['client']);     $start_date = $db->real_escape_string($_get['start_date']);     $end_date = $db->real_escape_string($_get['end_date']);     $jobs = array();     $htmlstring = '';     // list of jobs db & save array     $query = "select somecolumns mydatabase start_date > '{$start_date}' , end_date < '{$end_date}' , client = '{$client}'";     if(!$result = $db->query($query))     {         die('there error running query [' . $db->error . ']');     }     while($r = mysqli_fetch_assoc($result))      {         $jobs[] = $r;     }     // loop through jobs array , formulate html string     foreach($jobs $value)     {         $id = $value['id'];         $name = $value['name'];         $tech = $value['tech'];         $time_closed = $value['time_closed'];         $time_total = $value['time_total'];         $time_charged = $value['time_charged'];         $description = $value['description'];          $htmlstring = $htmlstring . <<<eot                 <h4 style="text-align: center;">{$id} - {$name}</h5>                     <table id="simple-table" class="table table-striped table-bordered table-hover">                         <thead>                             <tr>                                 <th style="width: 180px;">date</th>                                 <th>description</th>                                 <th style="width: 50px;">duration</th>                                 <th style="width: 150px;">time charged</th>                                 <th style="width: 150px;">technician</th>                             </tr>                         </thead>                         <tbody id="jobs_start">                             <tr>                                 <td>{$time_closed}</td>                                 <td>{$description}</td>                                 <td>{$time_total}</td>                                 <td>{$time_charged}</td>                                 <td>{$tech}</td>                             </tr>                         </tbody>                     </table> eot;     }      $pdf = new pdf($htmlstring);     $pdf->setoptions(array(         'orientation' => 'landscape'     ));      $pdf->saveas('new.pdf');  ?> 

when try run above browsing testpdf.php logged in user, nothing. no file generated , no error/warning in error logs. i've tried using $pdf->send() no success.

my initial thought permissions issue, i've tried setting testpdf.php owner root , permission 755 still not resolve issue.

the issue when sending html string pdf object, looks tag determine if it's html.

the first example has html tag, while 2nd file not have html tag fails, silently.

https://github.com/mikehaertl/phpwkhtmltopdf/blob/master/src/pdf.php


Popular posts from this blog