wkhtmltopdf不生成pdf文件

时间:2017-01-11 06:04:51

标签: php pdf wkhtmltopdf

我想将html文件转换为pdf文件。我在我的电脑上安装了wkhtmltopdf。我有以下代码将html文件转换为pdf文件。

$data = '<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <h1>Lorem Ipsum</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod laboriosam atque, consequuntur beatae fugiat in incidunt perspiciatis dolorem ipsum nam itaque animi nobis quam illum dolore. Nam nostrum maiores, ipsa.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa vero veniam sed ullam commodi! Accusantium, officia vitae, adipisci mollitia, blanditiis voluptates accusamus nam atque repellendus laborum, ullam vel eligendi esse?</p>
</body>
</html>';

file_put_contents('test.html', $data);

$html_file_url = 'http://localhost/document-editor/test.html'; // html file 
$pdf_file_url = 'C:\\test.pdf'; // pdf file 

//$cmd = "C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf http://localhost/";//$html_file_url $pdf_file_url";// command 
$cmd = "c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf $html_file_url $pdf_file_url";// command 
//c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf
exec($cmd);

但是没有生成pdf文件。问题出在哪儿 ?请帮我 。

0 个答案:

没有答案