Skip to content
Advertisement

DOMPDF Chinese Character

I have problem that when I download the PDF it will download the font together in the PDF which will create a very big size of PDF (about 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"); ?>

Advertisement

Answer

You’ll want to enable font subsetting.

In dompdf 0.6.2 or earlier set the DOMPDF_ENABLE_FONTSUBSETTING configuration constant to true. Configuration constants can be set in dompdf/dompdf_config.custom.inc.php.

In dompdf 0.7.0 or later after you instantiate dompdf you can configure this option using the set_option method: $dompdf->set_option('isFontSubsettingEnabled', true);.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement