简体   繁体   English

如何处理FPDF中的特殊字符

[英]How to handle special characters in FPDF

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. 我目前正在使用FPDF创建pdf,但意识到FPDF类似乎无法处理特殊字符,例如波浪号。 I know the strings coming from my database are UTF-8, but these characters get stripped out anyway. 我知道来自数据库的字符串是UTF-8,但是无论如何这些字符都会被剥离掉。 I've tried changing the character set, like this: 我尝试过更改字符集,如下所示:

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

But, still nothing. 但是,仍然没有。 Is there any other solutions, other than using tFPDF? 除了使用tFPDF之外,还有其他解决方案吗? I've made some substantial changes to the original FPDF class and don't want to have to redo it all. 我已经对原始的FPDF类进行了一些实质性的更改,并且不想全部重做。

thanks jason 谢谢杰森

EDIT 编辑

When I use FPDF and try to print something like this: 当我使用FPDF并尝试打印以下内容时:

   $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');

And it prints out: 它打印出来:

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

Checkout the extension of FPDF/HTML2PDF called mPDF that allows Unicode fonts. 检出名为mPDF的FPDF / mPDF扩展名,该扩展名允许Unicode字体。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM