Php 添加非默认字体时DomPdf未对齐文本

Php 添加非默认字体时DomPdf未对齐文本,php,fonts,dompdf,text-align,Php,Fonts,Dompdf,Text Align,我正在尝试创建一个小应用程序,其中一个模块应该打印公司徽章,我创建了一个基本代码只是为了测试,但是图像居中,而文本没有 <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Carnets</title> </head> <body> <?php require_once 'dompdf/autoload.inc.ph

我正在尝试创建一个小应用程序,其中一个模块应该打印公司徽章,我创建了一个基本代码只是为了测试,但是图像居中,而文本没有

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Carnets</title>
</head>
<body>
<?php

require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;

$html = 
'<table style="height: 506.5px; width: 319px;" border="0" align="center">
<tbody>
<tr>
<td align="center"><img src="archivos\logo.jpg" alt="logoAig"/><br><br><br></td>
</tr>
<tr>
<td align="center"><img src="archivos\USUARIO.jpg" width="300" height="300" alt="usuario"/><br><br><br><br></td>
</tr>
<tr>
<td style="text-align:center;"><span style="font-family: aigfuturamed; font-size: 32; color: rgb(0,164,228);">NAME</span></td>
</tr>
<tr>
<td style="text-align:center;"><br><br><span style="font-family: aigfuturamed; font-size: 24; color: rgb(0,164,228);">LASTNAME</span></td>
</tr>
</tbody>
</table>';

function creaCarnet($html){
    // instantiate and use the dompdf class
    $html = '<html><body>'.$html.'</body></html>';
    $dompdf = new Dompdf();
    $dompdf->loadHtml($html);

    // (Optional) Setup the paper size and orientation
    $dompdf->setPaper(array(0,0,319,506.5), 'portrait'); 

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

    // Get the generated PDF file contents
    $pdf = $dompdf->output();

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

//echo $html;
creaCarnet($html);
?>



</body>
</html>

卡内特
在网站上显示HTML时,所有单词都居中,但打印PDF时根本不起作用。我错过了什么?我使用的字体是Futura的一个特殊版本,如果我与其他字体一起使用,或者没有选择字体,请不要介意,问题仍然存在

dompdf的版本为:0.6.2

关于这个问题的新信息,我重新开始,没有之前运行过的所有其他测试,创建了一个新文件,它工作“很好”,因为它确实对齐了文本。然而,当我添加新字体时,现在的问题是,如果我去使用任何标准默认字体,我没有问题,但因为公司政策要求在我去选择使用load_font.php创建的字体“aigfuturamed”时使用这种特殊字体,我就有问题了

以下是dompdf\u font\u family\u cache.dist中添加的信息:

'aigfuturamed'=>
排列(
“普通”=>DOMPDF\u字体\u目录。“爱富图拉中号”,
“粗体”=>DOMPDF\u FONT\u DIR.“AIGFutura中型”,
‘italic’=>DOMPDF_FONT_DIR.‘AIGFutura Medium’,
'bold_italic'=>DOMPDF_FONT_DIR.'AIGFutura Medium',
),

这是当前的结果:

这就是我想要的结果:

您尝试过wkhtmltopdf吗?它需要安装在服务器上,但是使用起来非常好。至于dompdf,我以前使用过样式文本algin:center,它使用dompdf将文本居中。不确定在你的情况下发生了什么。根本不起作用,就像单词左对齐一样?还是文字偏离了中心?你能分享一个PDF输出的例子吗?对不起,忘记添加图片了,我现在已经添加了。