使用php和dompdf以PDF格式导出变音符号

时间:2014-08-29 13:43:28

标签: php pdf codeigniter-2 php-5.3 dompdf

我在PDF文档中导出重音字符(例如“şăţî”)时遇到问题。这些字符通常存储在数据库中,但当我尝试导出为PDF时,字符ş将转换为%C5%9F,依此类推。我认为问题来自dompdf库。现在我做preg_replace但不是一个好的解决方案。有人遇到过这样的问题吗?

我的代码:

   public function generateTitlePage($company, $number_cadastral='', $adresa_beneficiar='', $administrator='',                                      $verificator='', $number_certificate='', $executor='', $date='')
{
    $this->load->library('dompdf_gen');
    $dompdf = new DOMPDF();
    $company = preg_replace('/%C3%A2/','â',$company);
    $company = preg_replace('/%C3%AE/','î',$company);
    $company = preg_replace('/%C5%9F/','ş',$company);
    $company = preg_replace('/%C5%A3/','ţ',$company);



    $html = <<<HTML
        <html>
        <head>
            <meta charset="UTF-8">
        </head>
        <body>
            <div style="margin-top:20px;text-align: center;font-weight: bold">SOCIETATE CU RASPUNDERE LIMITATA&nbsp;$company</div>
            <div style="margin-top: 100px; text-align: right; padding-right:130px;">
                <span style="padding-right: 10px">Nr.Cadastral:</span>$company
                <div style="width: 150px;margin-left: 535px;size:1;"><hr style="margin:0px;"></div>
            </div>
 </body>
        </html>
 HTML;

    $dompdf->load_html($html);
    $dompdf->render();
    $dompdf->stream("welcome.pdf");
}

有空格我有同样的问题;空格转换为.%2727%

0 个答案:

没有答案