使用WkHtmlToPdf生成PDF时找不到Bin存档。知道为什么吗?

时间:2013-10-15 19:51:42

标签: php pdf-generation laravel-4 wkhtmltopdf html2pdf

我正在尝试使用WkHtmlToPdf从之前形成的HTML生成PDF,暂时存储在文件中。

$pdf = new WkHtmlToPdf(array('bin' => $this->getVendorsPath() . 'h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'));
$html = file_get_contents($this->getPublicPath().'file.tmp');
$pdf->addPage($html);

if(!$pdf->saveAs($this->getPublicPath() . 'file.pdf'))
    echo "Erro on PDF generating. Error: " . $pdf->getError();

其中:

  1. $ this-> getVendorsPath()是供应商文件夹的路径,以“/”(斜杠)结尾
  2. file_get_contents($ this-> getPublicPath()。'file.tmp'):由于内存问题,我不得不将html放在临时文件中,并在PDF进入播放时调用它。
  3. 调用控制器后,$pdf->getError()给出了错误:

    Erro on PDF generating. Error: Could not run command '/var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64' /tmp/tmp_WkHtmlToPdf_Rgqz5E.html /tmp/tmp_WkHtmlToPdf_qOAH5u: /var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: 1: /var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: 8: not found /var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: 2: /var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: Syntax error: ")" unexpected /var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: 1: /var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: cannot create �A�o��@/�N: Directory nonexistent /var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: 1: /var/www/{projects_name}/app/controllers/../../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64: ELF: not found
    

    很抱歉这一切都在一行中,但我不确定在没有丢失信息的情况下分成小行。

    编辑:WkHtmlToPdf的来源=> http://mikehaertl.github.io/phpwkhtmltopdf/

0 个答案:

没有答案