设置为仅在第一页上呈现的CSS字体,其后为Times ne Romanmpdf

问题描述

在CSS中,我将字体系列设置为font-family:DejaVu Sans,它可以工作,但仅在生成的PDF的第一页上,随后的页面是Times New Roman。

PHP 7.2.24 / ubuntu mPdf 8.0。

在本地(Windows)上一切正常。

  $html = "
    <!DOCTYPE html>
    <html>
      <head>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
        <style  type=\'text/css\'> html { margin-top: 70px} p,ul,ol{font-size:14px!important;} h2{font-size:20px!important; margin-bottom: 10px!important;} h3{font-size:16px!important;} figcaption{font-size:12px!important;} figure{text-align: center;} img{max-width: 500px;}
          .section-newsletter,.wp-block-share-quote-share-quote-block,.acf-section-conversion,{ opacity:0;}
          header { width:100%; text-align: center;}
          body{font-family: DejaVu Sans; sans-serif; font-weight: normal;}
        </style>
      </head>
      <body>
 ";
  $html .= "<h1 style='text-align: center; font-weight: bold;'> $post->post_title </h1>";
  $html .= '<article>' . $post->post_content . '</article>';
  $html .= "</body></html>";

  $mpdf = new \Mpdf\Mpdf([
    'format' => 'A4-P','margin_top' => 25,'margin_header' => 10,'margin_bottom' => 25,]);

  $mpdf->SetHTMLHeader("
  <div style='text-align: right; font-weight: bold;'>
  <header><a href='https://www.com'><img style='display:inline-block;' src='https://www.com/wp-content/themes/theme/resources/images/logo.svg' alt='www logo'></a></header>
  </div>");
  $Htmltemp = str_replace('https://www.com/wp-content/uploads/','wp-content/uploads/',$html);
  $mpdf->SetAuthor("XYZ");
  
);
$mpdf->SetFooter($footer);

  $mpdf->WriteHTML($Htmltemp);

  $mpdf->Output($url . '/pdfs/' . $postIdMd . '.pdf','F');
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...