【问题标题】:wkhtmltopdf does not create pdf for Debianwkhtmltopdf 不会为 Debian 创建 pdf
【发布时间】:2013-01-16 05:45:57
【问题描述】:

这是我的 PHP 代码,用于将 HTML 文件转换为 pdf,然后从服务器下载 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 $url {$file_folder}{$file_name}.pdf");它不会在文件夹中创建 pdf 文件

Ubuntu 上运行良好,但在 Debian 上下载 pdf 后,打开 pdf 时 Adob​​ Reader 显示错误,请查看图片。

我认为问题是由于 exec() 无法在 Debian 中工作...!

wkhtmltopdf

【问题讨论】:

    标签: php debian wkhtmltopdf


    【解决方案1】:

    在下载文件期间检查 base_url() 中的路径是否传递了正确的路径, 测试在浏览器中记下路径并检查它是否被下载

    【讨论】:

    【解决方案2】:

    对于 Debian,我需要安装 xvfb-run wkhtmltopdf

    【讨论】:

    • 我必须安装 xvfb-run 但总是喜欢这种情况,我可以得到具体的解决方案,也许是配置等,谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-13
    • 2014-01-06
    • 1970-01-01
    • 2019-07-10
    • 2017-12-24
    • 2013-12-25
    相关资源
    最近更新 更多