2013-01-16 60 views
0

这是我用来将HTML文件转换为pdf然后从服务器下载pdf文件的PHP代码。wkhtmltopdf不为Debian创建pdf

wkhtmltopdf

$url = base_url().'invoices/'.$file_name.'.html';      
exec("wkhtmltopdf-amd64 $url {$file_folder}{$file_name}.pdf"); 

header("Cache-Control: no-cache"); 
header("Content-Description: File Transfer"); 
header("Content-Disposition: attachment; filename=$file_name.pdf"); 
header("Content-Type: application/pdf"); 
header("Content-Transfer-Encoding: binary"); 
$pdfFile = base_url().'invoices/'.$file_name.'.pdf'; 
readfile($pdfFile); 

&后执行的exec( “wkhtmltopdf-AMD64 $网址{$ file_folder} {$ FILE_NAME} .PDF”);它不

它下载PDF后工作正常上Ubuntu的Debian的,当打开PDF Adob​​读者说错误,请查看图像的文件夹中创建PDF文件。

我认为这个问题是由于exec()不工作在Debian ...!

enter image description here

wkhtmltopdf

回答

0

对于Debian我需要安装xvfb的经营wkhtmltopdf

0

您在BASE_URL路径()是该文件的下载, 期间传递正确的道路测试,在浏览器中记下的路径,并检查它是否会下载或不

+0

ULR指向利用了W正确的,遗憾的一件事多个IM khtmltopdf&执行exec后(“wkhtmltopdf-amd64 $ url {$ file_folder} {$ file_name} .pdf”);它不会在该文件夹中创建PDF文件。 –

+0

这就是它发生的情况,当没有文件或正确的格式,错误给出和wkhtmltopdf这可能会帮助你[http://stackoverflow.com/questions/8881315/linux-permissions-issue-when-executing -wkhtmltopdf-AMD64](http://stackoverflow.com/questions/8881315/linux-permissions-issue-when-executing-wkhtmltopdf-amd64) – somesh