dongzhuang5741 2014-08-29 13:43
浏览 24

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

I have a problem with exporting accented characters such as "şăţî" in PDF documents. These characters are stored normally in a database but when I tried to export to PDF the character ş is transformed to %C5%9F and so on. I think the problem is from dompdf library. Now I do preg_replace but is not a good solution. Someone was met with such problem?

My code:

   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");
}

With blank spaces I have the same problem; blank space is transformed into .%27 and 27%.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡等级和折扣规则
    • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分