"Wkhtmltopdf didn't return any data" 使用 CakePHP

"Wkhtmltopdf didn't return any data" with CakePHP

我是 运行 CakePHP 2.8 环境,想用 wkhtmltopdf 打印 PDF。曾经,我可以创建一个 PDF,然后,我有几个星期没有使用它,因为我正在处理其他事情。今天我重新开始处理它并收到错误消息:

"WKHTMLTOPDF didn't return any data" 

APP/Plugin/CakePdf/Pdf/CakePdf.php line 236 → WkHtmlToPdfEngine->output()
APP/Plugin/CakePdf/View/PdfView.php line 97 → CakePdf->output(string)
CORE/Cake/Controller/Controller.php line 963 → PdfView->render(null, null)
CORE/Cake/Routing/Dispatcher.php line 200 → Controller->render()
CORE/Cake/Routing/Dispatcher.php line 167 → Dispatcher->_invoke(InvoicesController, CakeRequest)
APP/webroot/index.php line 109 → Dispatcher->dispatch(CakeRequest, CakeResponse)

我的机器是配备 El Capitan 的 MacBook Pro。此外,我认为它可能是 El Capitan 更新,但后来我将 wkhtmltopdf 安装到与 CakePHP 2.8 相同的系统上,并且它在本机上是 运行。不幸的是,我不知道我能做什么。我重新安装了 wkhtml 并再次更新了 CakePHP,但是没有机会:-(

谁能帮帮我?

终于,我做到了。 我首先删除了 usr/local/bin 上的所有 wkhtmltopdf /img 文件,然后将 wkthmltopdf 从 64 位更改为 32 位。虽然我有一个 64 位系统,但它可以使用 32 位而不是 64 位。不要问我为什么它有效,但它对我有效!

同样的错误,我的情况不同。

我发现,那个问题是QT补丁。然后 wkhtmltopdf 缺少一些功能,它在 wkhtmltopdf help

的底部说明
Reduced Functionality:
  This version of wkhtmltopdf has been compiled against a version of QT without
  the wkhtmltopdf patches. Therefore some features are missing, if you need
  these features please use the static version.

  Currently the list of features only supported with patch QT includes:

 * Printing more than one HTML document into a PDF file.
 * Running without an X11 server.
 * Adding a document outline to the PDF file.
 * Adding headers and footers to the PDF file.
 * Generating a table of contents.
 * Adding links in the generated PDF file.
 * Printing using the screen media-type.
 * Disabling the smart shrink feature of WebKit.

解决方案是使用补丁版本:

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
mv wkhtmltox/bin/wkhtmlto* /usr/bin/
ln -nfs /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf

来源:https://gist.github.com/yajra/80ae402e2084191cd1f6e17fa581320e