如何处理FPDF中的特殊字符 [英] How to handle special characters in FPDF

查看:213
本文介绍了如何处理FPDF中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用FPDF创建pdf,但意识到FPDF类似乎无法处理特殊字符,例如波浪号.我知道来自数据库的字符串是UTF-8,但是无论如何这些字符都会被剥离掉.我尝试过更改字符集,如下所示:

I am currently using FPDF to create pdf's but realized that the FPDF class doesn't seem to be able to handle special characters, like tilde's for example. I know the strings coming from my database are UTF-8, but these characters get stripped out anyway. I've tried changing the character set, like this:

$myString= iconv('UTF-8', 'windows-1252', $someString);

但是,仍然没有.除了使用tFPDF之外,还有其他解决方案吗?我已经对原始的FPDF类进行了一些实质性的更改,并且不想全部重做.

But, still nothing. Is there any other solutions, other than using tFPDF? I've made some substantial changes to the original FPDF class and don't want to have to redo it all.

谢谢 杰森

编辑

当我使用FPDF并尝试打印以下内容时:

When I use FPDF and try to print something like this:

   $this->SetFont( 'Arial', 'B', 19 );
   $this->SetLineWidth(1);
   $this->Line(10,10,290 ,10);
   $this->Cell(300,15,iconv("UTF-8", "CP1250//TRANSLIT",'Días, Miércoles, Sábado,miércoles, Año'),0,1,'C');

它会打印出来:

Dias,Miércoles,Sábado,miércoles,A〜no

Días, Miércoles, Sábado,miércoles, A~no

推荐答案

签出名为mPDF的FPDF/HTML2PDF扩展名,该扩展名允许Unicode字体.

Checkout the extension of FPDF/HTML2PDF called mPDF that allows Unicode fonts.

http://www.mpdf1.com/mpdf/index.php

这篇关于如何处理FPDF中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆