FriendsOfCake/CakePdf

mpdf version 7 fails, wrong tmp path

digitalfotografen opened this issue · 2 comments

The tmp file handling has been changed between mpdf 6.x and 7.x
https://mpdf.github.io/installation-setup/folders-for-temporary-files.html

The result is that CakePDF fails to generate PDF-files with MpdfEngine if page includes images that must be stored in tmp.

Solution is to add temp configuration in the MpdfEngine options 'tempDir' => TMP otherwise it tries to use the tmp folder inside #vendor/mpdf/mpdf.

Log dump:
2018-03-09 07:56:39 Error: [Mpdf\MpdfException] Temporary files directory "/var/www/checkimage/vendor/mpdf/mpdf/src/Config/../../tmp" is not writable in /var/www/checkimage/vendor/mpdf/mpdf/src/Cache.php on line 23
Request URL: /folders/view/13571bef-ca33-4853-995e-3be16b4dead2.pdf
Referer URL: https://demo.checkimage.se/folders/view/13571bef-ca33-4853-995e-3be16b4dead2
Client IP: 155.4.253.174
Stack Trace:
#0 /var/www/checkimage/vendor/mpdf/mpdf/src/Mpdf.php(980): Mpdf\Cache->__construct('/var/www/checki...')
#1 /var/www/checkimage/vendor/friendsofcake/cakepdf/src/Pdf/Engine/MpdfEngine.php(46): Mpdf\Mpdf->__construct(Array)
#2 /var/www/checkimage/vendor/friendsofcake/cakepdf/src/Pdf/Engine/MpdfEngine.php(32): CakePdf\Pdf\Engine\MpdfEngine->_createInstance(Array)
#3 /var/www/checkimage/vendor/friendsofcake/cakepdf/src/Pdf/CakePdf.php(299): CakePdf\Pdf\Engine\MpdfEngine->output()
#4 /var/www/checkimage/vendor/friendsofcake/cakepdf/src/View/PdfView.php(119): CakePdf\Pdf\CakePdf->output('...')
#5 /var/www/checkimage/vendor/cakephp/cakephp/src/Controller/Controller.php(623): CakePdf\View\PdfView->render(NULL, NULL)
#6 /var/www/checkimage/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(125): Cake\Controller\Controller->render()
#7 /var/www/checkimage/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(93): Cake\Http\ActionDispatcher->_invoke(Object(App\Controller\FoldersController))
#8 /var/www/checkimage/vendor/cakephp/cakephp/src/Routing/Dispatcher.php(60): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#9 /var/www/checkimage/webroot/index.php(36): Cake\Routing\Dispatcher->dispatch(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#10 {main}

ADmad commented

Can you please submit a patch to fix the issue?

Hi, now there is a patch for this issue #241
Thanks for a great Cake and useful extension!!!
/Ulrik