dompdf fails to load

Mark T. Johns picture Mark T. Johns · Feb 22, 2013 · Viewed 44.3k times · Source

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.

Answer

Mikepote picture Mikepote · Jul 1, 2014
  • Go to https://github.com/PhenX/php-font-lib and download the library.
  • Create the dompdf/lib/php-font-lib/classes/ directory.
  • In the zip file, take the contents of the src/FontLib/ folder and paste that into your newly created directory.

That seemed to work for me.