无法使用PDFLib适配器和最新的dompdf 0.7.0

时间:2016-07-01 06:01:40

标签: php dompdf pdflib

我使用DomPDF和PDFLib作为后端。

最近我正在尝试将我的应用程序升级为使用从0.6.0到0.7.0的dompdf。

但它在以下文件中给出了异常:

https://github.com/dompdf/dompdf/tree/master/src/Adapter/PDFLib.php#L213

$families = $dompdf->getFontMetrics->getFontFamilies();

例外:

[Dompdf\Exception, 0]
Invalid property: getFontMetrics

有谁能让我知道这个错误是什么?

以下是我尝试运行的示例php脚本:

<?php
require_once('dompdf/autoload.inc.php');

// reference the Dompdf namespace
use Dompdf\Dompdf;
use Dompdf\Options;

$options = new Options();
$options->set(array(
        'pdfBackend'=>'PDFLib',
        'defaultMediaType'=>'print',
        'defaultPaperSize'=>'A4',
        'defaultFont'=>'arial',
        'enable_html5_parser'=>true,
        'enable_font_subsetting'=>true
));

// instantiate and use the dompdf class
$dompdf = new Dompdf($options);
$dompdf->loadHtml('hello world');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
$dompdf->stream();

1 个答案:

答案 0 :(得分:0)

对于PDFLib,0.7.0中存在一些错误。下一个版本应解决这些问题(提交3fd379b解决此特定问题)。目前没有设定发布日期,但我预计会在今年秋天看到它。

相关讨论存在问题#1222