I am trying to generate a PDF that will contain Chinese characters using dompdf. Here is my code:
require(\'dompdf/dompdf_config.inc.php\');
$dompdf = new DO
First, move def("DOMPDF_UNICODE_ENABLED", true);
above the require since the def
function included with dompdf only defines the constant if it doesn't exist. When you include dompdf_config.inc.php that constant will be set at that time. Also, use define
instead.
Second, you need a different font. The DejaVu fonts included with dompdf do not support CJK. For an overview read my answer to Dompdf and set different font-family.
If you do not currently have a font you might try looking up Firefly Sung. Whatever font you decide to use it should be TTF in order for dompdf to use it.
Here's an example using Firefly Sung via the @font-face CSS rule, no installation required:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
@font-face {
font-family: 'Firefly Sung';
font-style: normal;
font-weight: 400;
src: url(http://eclecticgeek.com/dompdf/fonts/cjk/fireflysung.ttf) format('truetype');
}
* {
font-family: Firefly Sung, DejaVu Sans, sans-serif;
}
</style>
</head>
<body>
<div>忠烈祠</div>
</body>
</html>