title: PHP shell_exec 'wkhtmltopdf' returns null even though successful completion
body: <p>In the <a href="http://php.net/manual/es/function.shell-exec.php" rel="nofollow noreferrer">docs for PHP shell_exec</a> it says that that shell_exec function will return <code>null</code> if an error occurs.  Unfortunately when I run the following code, the code all completes correctly, but the shell_exec command still returns <code>null</code>.</p>
  
  <pre><code>// convert to PDF
  $output = shell_exec('wkhtmltopdf --page-size Letter report.html report.pdf');
  if (is_null($output)){
      echo("error creating pdf, please contact IT administrator.");
  }
  </code></pre>
  
  <p>I can tell it completes correctly because 1) the PDF file is created correctly, and 2) because I check the apache error_log (which for some reason contains the output for the wkhtmltopdf command) and the output says each step of the process completed correctly.</p>
  
  <p>This is a problem because I can't tell from the PHP program if the command completed correctly or not.  So the above script always dies with the error message even though no error occurred.</p>
  
  <p>This is the output is the apache error log (which is identical the the output on the command line when executing directly from the command line):
  <img src="https://i.stack.imgur.com/h8lPS.png" alt="enter image description here"></p>
  
  <p>Does anyone know why this is happening?  or how I can do this differently to correctly report the errors?</p>
  
  <blockquote>
    <p>Linux Ubuntu 12.10 </p>
    
    <p>PHP 5.3.6-13ubuntu3.9</p>
  </blockquote>