I am trying to get dompdf running on an in-house server. With the default config.inc.php settings, I get the following when running the equivalent of the demo 'Hello Wolrd' script:
Warning: require_once(/var/www/dompdf-master/lib/php-font-lib/classes/font.cls.php): failed to open stream: No such file or directory in /var/www/dompdf-master/dompdf_config.inc.php on line 335
Fatal error: require_once(): Failed opening required '/var/www/dompdf-master/lib/php-font-lib/classes/font.cls.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/dompdf-master/dompdf_config.inc.php on line 335
When I turn off DOMPDF_ENABLE_AUTOLOAD
, I no longer get this warning, but the code fails with the following:
Fatal error: Class 'DOMPDF' not found in /var/www/rfq/test.php on line 115
The following is the code:
require_once("/var/www/dompdf-master/dompdf_config.inc.php");
$dompdf = new DOMPDF(); // this is the line that fails
$dompdf->load_html($quotehtml);
$dompdf->render();
$dompdf->stream("rfq".$_REQUEST['quoteid'].".pdf");
This is Ubuntu 12.04, up-to-date on patches, with default Apache settings.
Thanks so much.
I had almost the exact same problem. My code was working on my local dev machine - a Windows box - but then was failing on our production server - a Linux box
The problem was that the "classes" directory was lower case (\app\Vendor\dompdf\lib\php-font-lib\classes) which windows did not mind - but Linux being case-sensitive did!
Simply editing the following line in dompdf_config.inc.php solved the problem:
For consistency I renamed the directory with an uppercase "C" on the Windows box.
dompdf/lib/php-font-lib/classes/
directory.src/FontLib/
folder and paste that into your newly created directory.That seemed to work for me.
If error is not corrected after doing what other answers suggest:
There is no CLASSES folder that was mentioned there.
If you are using composer to install dompdf, you need to put
define("DOMPDF_ENABLE_AUTOLOAD", false);
in dompdf_config.custom.inc.php. This will then allow composer to autoload the php-font-lib as it is already installed. (See this issue: https://github.com/dompdf/dompdf/issues/636)If you are not using composer, see Mikepote's answer.
We will use dompdf in codeigniter BUT the file that I’v downloaded from GitHub doesn’t has all the files that we need. Is missing all the files of php-font-lib. So we had to download it and uploaded to the respective folder. So, to have dompdf working in codeigniter you might have to download it.
See here http://www.digitalwhores.net/codeigniter/codeigniter-dompdf-master-and-php-font-lib/
The new version of dompdf doesn't work with 'composer install' or 'composer update'. It needs special versions of font libraries which might not always be the latest versions, so this might change in future. But you can find how to install it via dompdf's documentation. Dont know why the authors haven't hardcoded these font versions inside the composer.json, but anyways here is how to do it.
Currently the easiest and best way of using the library is via git (taken from the official docs)
Then you can just do