| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/nick/codeigniter/application/views/webadmin/ |
Upload File : |
<?php
use Dompdf\Dompdf;
$body = 'test 简化字 彝語/彝语 アメリカ test číslo € černý Češký test 深水埗 嘅 啲';
$cjk_scripts = 'Bopomofo|Han|Hiragana|Katakana';
$cjk_scripts = preg_replace('/[a-zA-Z_]+/', '\\p{$0}', $cjk_scripts);
// wrap the CJK characters into a span with it's own font
$body = preg_replace("/($cjk_scripts)+/isu", '<span class="cjk">$0</span>', $body);
// a font that supports CJK characters
// $cjk_font_path = FCPATH.'assets/fonts/DroidSansFallbackFull.ttf';
$cjk_font_path = FCPATH.'assets/fonts/msjh.ttf';
// vdump(file_exists($cjk_font_path));exit;
$html = <<<HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
@font-face {
font-family: 'DroidSansFallbackFull';
font-style: normal;
font-weight: 400;
src: url('$cjk_font_path') format('truetype');
}
body {
font-family: DejaVu Sans, sans-serif;;
}
.cjk {
font-family: DroidSansFallbackFull, sans-serif;
}
</style>
</head>
<body>$body</body>
</html>
HTML;
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'landscape');
$dompdf->set_option('defaultFont', 'Courier'); // 預設字型(僅支援英文)
$dompdf->render();
// Attachment: 0 直接顯示, 1 強制下載
$dompdf->stream(null, ['Attachment' => 0]);