本文介绍了PHP-font-lib必须通过作曲家安装或复制到lib/php-font-lib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些html转换为pdf.经过一些Google搜索后,我找到了 dompdf ,但是当我尝试进行转换时,我便找到了

i'm trying to convert some html to pdf. After some google search i find dompdf but when i try to convert i retrieve

PHP-font-lib must either be installed via composer or copied to lib/php-font-lib

这就是我想要做的:

require 'pdf/dompdf.php';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");

我该如何解决?谢谢!

推荐答案

Dompdf最近移至 Github ,并且我们还添加了Composer支持.为此,我们删除了对所需外部库 php-font-lib 的引用.

Dompdf moved recently to Github, and we also added Composer support. For this, we removed the reference to the required external library php-font-lib.

注意:如果您使用Composer安装dompdf(和 php-font-lib ),则需要将define("DOMPDF_ENABLE_AUTOLOAD", false);放入dompdf_config.custom.inc.php中.然后,这将允许作曲者自动加载通过dompdf的作曲者安装的 php-font-lib .json文件.否则,您可能仍然会收到错误消息. (请参见问题)

Note: If you are using composer to install dompdf (and php-font-lib), you need to put define("DOMPDF_ENABLE_AUTOLOAD", false); in dompdf_config.custom.inc.php. This will then allow composer to autoload php-font-lib which is installed through dompdf's composer.json file. Otherwise, you may still get an error. (See this issue)

如果您不使用composer并希望通过该库使用最新版的dompdf :( )

If you are not using composer and want to use the latest edition of dompdf with this library: (source)

  • Github 获取最新的dompdf版本,并将其提取到目录中.
  • 也可以从 Github
  • 下载该库版本.
  • 创建dompdf/lib/php-font-lib/classes/目录.
  • 在zip文件中,获取src/FontLib/文件夹的内容并将其粘贴到新创建的目录中.
  • Get the latest dompdf release from Github and extract it into a directory.
  • Download the library release also from Github
  • 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.

这篇关于PHP-font-lib必须通过作曲家安装或复制到lib/php-font-lib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 17:47