dompdf fails to load

假如想象 提交于 2019-11-30 04:26:39
  • 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.

Jpsy

This is a temporary issue after the DOMPDF project moved to Github. See the answers to this question. The easiest solution to get the complete package is to download DOMPDF 0.6 beta 3 from Google Code.

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/

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.

If error is not corrected after doing what other answers suggest:

In dompdf_config.inc.php, change line 332 to point to the actual location of your Font.php  file.
mine was /php-font-lib/src/FontLib

There is no CLASSES folder that was mentioned there.

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:

require_once(DOMPDF_LIB_DIR . "/php-font-lib/Classes/Font.php");

For consistency I renamed the directory with an uppercase "C" on the Windows box.

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)

git clone https://github.com/dompdf/dompdf.git
cd dompdf

git clone https://github.com/PhenX/php-font-lib.git lib/php-font-lib
cd lib/php-font-lib
git checkout 0.4
cd ..

git clone https://github.com/PhenX/php-svg-lib.git php-svg-lib
cd php-svg-lib
git checkout v0.1

Then you can just do

use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream( "/path-to-save-pdf-file/sample.pdf");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!