“Wkhtmltopdf didn't return any data” with CakePHP

ぃ、小莉子 提交于 2021-01-28 20:05:23

问题


I am running a CakePHP 2.8 environment and want to print a PDF with wkhtmltopdf. Once, I could create an PDF, then, I didn't used it for few weeks because I was working on something else. Today I restarted to work on that and got the error Message:

"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)

My machine is a MacBook Pro with El Capitan. Furthermore, I thought that it might be the El Capitan Update, but then I installed wkhtmltopdf to an equal system with CakePHP 2.8 and it is running on this machine. Unfortunately, I have no idea what I can do. I reinstalled wkhtml and updated CakePHP again, but no chance :-(

Can anyone help me?


回答1:


Finally, I did it. I first deleted all wkhtmltopdf /img files on usr/local/bin and then changed the wkthmltopdf from 64bit to 32bit. Although I have a 64bit system, it is working with the 32bit but not the 64bit. Don't ask me why it is working, but it works for me!




回答2:


Same error, different cause in my case.

I found out, that problem was QT patch. Then wkhtmltopdf lacks some features and it is stated at bottom of 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.

Solution is to use patched version:

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

Source: https://gist.github.com/yajra/80ae402e2084191cd1f6e17fa581320e



来源:https://stackoverflow.com/questions/35563569/wkhtmltopdf-didnt-return-any-data-with-cakephp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!