DOMPDF汉字

时间:2016-03-15 12:31:15

标签: php html dompdf

我有问题,当我下载PDF时,它会在PDF中一起下载字体,这将创建一个非常大的PDF(大约10mb +)。

<?php
include "/dompdf_config.inc.php";
$html =
  '<html><body><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <style>
  *{ font-family: simsun; }
  </style>
  <p>开发人员指南</p>
  </body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("hello.pdf"); ?>

2 个答案:

答案 0 :(得分:0)

您想要启用字体子集。

在dompdf 0.6.2或更早版本中,将DOMPDF_ENABLE_FONTSUBSETTING配置常量设置为true。配置常量可以在dompdf / dompdf_config.custom.inc.php中设置。

在实例化dompdf后的dompdf 0.7.0或更高版本中,您可以使用set_option方法配置此选项:$dompdf->set_option('isFontSubsettingEnabled', true);

答案 1 :(得分:0)

按照步骤在laravel最新版本中使用chinless语言支持

  1. 克隆https://github.com/dompdf/utils
  2. 从我使用 simsun https://www.wfonts.com/font/simsun 下载字体 3.1. 将这些文件保存在项目 rot 文件夹中 3.2 在存储文件夹中添加文件夹名称字体
  3. 从你的评论中运行 php load_font.php "Simsun" Simsun.ttf 5.然后在html body中使用{ font-family: 'Simsun'; } 中文enter image description here 语言 6.我附上图片,以便它会帮助你 enter image description here
相关问题