Reputation: 359
I followed this great tutorial
My View/Layouts/pdf/default.ctp
App::import('Vendor', 'dompdf/dompdf.php');
$dompdf = new DOMPDF();
$dompdf->load_html(utf8_decode($content_for_layout), Configure::read('App.encoding'));
$dompdf->render();
echo $dompdf->output();
My View/Bids/pfd/view.ctp
is a copy of my regular view for testing purposes.
If I remove php extension:
App::import('Vendor', 'dompdf/dompdf');
I get error:
An input file is required (i.e. input_file _GET variable).
Tried several combinations of require_once as well to no luck. (Even tried with another dompdf fresh download: (from Github, zip called dompdf-master)
App::import('Vendor', 'dompdf-master/dompdf.php');
and got same Class not found error.
If I remove php extension in this dompdf-master
App::import('Vendor', 'dompdf-master/dompdf');
got error:
PHP-font-lib must either be installed via composer or copied to lib/php-font-lib
I'm positive access is granted and files are where they are supposed to be, php 5.3.
It's supposed to be very simple according to mark's tutorial.
Can you help?
Thanks a lot !
Upvotes: 0
Views: 3735
Reputation: 13914
The correct file to load for setting up dompdf is dompdf_config.inc.php. dompdf does not currently follow the CakePHP File and Classname Conventions. Since you're loading the class directly instead of using a plugin that utilizes dompdf you'll have to be more explicit. Looking at the App::import() documentation in the CakePHP book, something like the following might work:
App::import($type = 'Vendor', 'DOMPDF', true, array(), 'dompdf_config.inc.php', false);
Of course, if you follow the advice in this answer, you should just use require:
require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
Finally, I recommend you drop the utf8_decode()
call, so long as you're using dompdf 0.6.0. dompdf 0.5.1 didn't handle UTF8 too well, but the latest release handles it just fine, so long as you've followed the advice in the Unicode How-to.
Your layout should thus look more like the following:
require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->load_html($content_for_layout);
$dompdf->render();
echo $dompdf->output();
Upvotes: 1