DomPDF在本地加载字体,但不在线加载


DomPDF loads font in local but not online

我想使用Arial作为PDF的字体。但它只能在本地网站上运行,而不能在网上运行。我正在和Codeigniter一起做这个项目。下面是我的代码。

 @font-face {
    font-family: "arial";
    src: url('<?php  echo admin_asset_url();?>/arial.ttf');
   }
 body,h1,h2,h3,li,a,p,h4{
        font-family: "arial";
    }
function pdf_create($html, $filename='', $stream=TRUE) 
{
    require_once("dompdf/dompdf_config.inc.php");
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename.".pdf");
    } else {
        return $dompdf->output();
    }
}

这可能是因为domPDF正在从服务器上加载字体,当访问本地主机时,可能是您的计算机。

另一方面,您的服务器可能没有安装arial。因此,它不起作用。

点击此链接了解更多关于domPDF和字体的信息