问题
I'm stuck on a problem which has got be stumped. I've installed the CakePdf plugin as per the instructions in the Read Me file. When I get to use the plugin however, I get a CakePHP error saying the following:
Pdf engine "wkhtmltopdf" not found
Error: An Internal Error Has Occurred. Stack Trace
APP/Plugin/CakePdf/Pdf/CakePdf.php line 193 → CakePdf->engine(string) APP/Plugin/CakePdf/View/PdfView.php line 74 → CakePdf->__construct(array) APP/Plugin/CakePdf/View/PdfView.php line 64 → PdfView->renderer(array) CORE/Cake/Controller/Controller.php line 942 → PdfView->__construct(UsersController) CORE/Cake/Routing/Dispatcher.php line 193 → Controller->render() CORE/Cake/Routing/Dispatcher.php line 161 → Dispatcher->_invoke(UsersController, CakeRequest, CakeResponse) APP/webroot/index.php line 96 → Dispatcher->dispatch(CakeRequest, CakeResponse)
I've checked the binary path that CakePdf uses, and this is the following code:
protected $binary = '/usr/bin/wkhtmltopdf';
I've navigated to the /usr/bin/ directory, and the wkhtmltopdf binary is there. I've also used the command wkhtmltopdf http://bbc.co.uk bbc.pdf
and it works. So I don't know why CakePHP/CakePdf can't find the plugin, even though it is located in the defined binary path?
Update
Here is the permissions etc for the wkhtmltopdf
binary:
-rwxrwxrwx. 1 root root 8301444 Aug 27 08:14 wkhtmltopdf
回答1:
There seems to be an error in the documentation.
When you call wkhtmltopdf
in the bootstrap.php file, instead of using:
'engine' => 'WkHtmlToPdf'
You need to use:
'engine' => 'CakePdf.WkHtmlToPdf'
instead.
This then fixes the issue.
来源:https://stackoverflow.com/questions/12137927/cakephp-cant-find-wkhtmltopdf-when-using-cakepdf-plugin