How can I make dompdf work with a Symfony 2.1 project?
I followed this TUTORIAL but I’m still getting this exception:
Notice: Use of undefined constant DOMPDF_LIB_DIR – assumed
‘DOMPDF_LIB_DIR’ in
[blablabla]/vendor/dino/dompdf/lib/DOMPDF/stylesheet.cls.php
line 16
if not this, what is the best and simplest library to create pdf from html with Symfony 2.1 ?
Here is what I’ve done to make DOMPDF available to me in a Symfony2 project:
require the DinoPDF composer package:
php composer.phar require dino/dompdf, version 0.1.1 (or dev-master)
DomPDF init files need to be required() somewhere in the loading process:
add in your app/autoload.php:
dompdf_config.inc.php defines the paths to your DOMpdf installation. DinoPDF distribution changed the paths within the library, so this has to be taken care of:
DOMPDF_INC_DIR: Main DOMPdf classes. In dinoPDF distribution of DOMPdf this folder is renamed from dompdf/include to dompdf/lib/DOMPDF
DOMPDF_LIB_DIR: Additional resources – fonts, etc. In dinoPDF distribution of DOMPdf this folder is renamed from dompdf/lib to dompdf/lib/vendor
Here are the changes I’ve introduced to dompdf_config.inc.php:
This should correctly include the library, so that it could be used in controllers, for ex. like this: