我正在运行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,但没有机会:-(
任何人都可以帮助我吗?
答案 0 :(得分:2)
最后,我做到了。 我首先删除了usr / local / bin上的所有wkhtmltopdf / img文件,然后将wkthmltopdf从64位更改为32位。虽然我有一个64位系统,但它使用32位而不是64位。不要问我它为什么有效,但它对我有用!
答案 1 :(得分:0)
相同的错误,在我的情况下是不同的原因。
我发现,问题出在QT补丁程序上。然后wkhtmltopdf缺少一些功能,并在wkhtmltopdf 帮助
的底部列出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