How to handle special characters in FPDF

浪子不回头ぞ 提交于 2019-12-25 01:12:01

问题


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

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.

thanks jason

EDIT

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

And it prints out:

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


回答1:


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

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



来源:https://stackoverflow.com/questions/23539844/how-to-handle-special-characters-in-fpdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!