程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

TFPDF Lithuanian letters

发布于2023-01-19 16:53     阅读(746)     评论(0)     点赞(3)     收藏(4)


I have a problem with lithuanian letters like ąčęėįšųūž. For that reason I use tfpdf and font DejaVu. When I get content from txt file, everything is fine but I give content just simply, then I get "????". Header charset is set utf-8.

ob_start();
require('../fpd/tfpdf.php');

$pdf = new tFPDF();
$pdf->AddPage();

// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',10);

// Load a UTF-8 string from a file and print it
$txt = file_get_contents('../fpd/HelloWorld.txt');
$pdf->Write(8,$txt);
$pdf->Ln(10);
$txt1 = "ąčęėįšųž";
$pdf->Write(8,$txt1);

$pdf->Output('filename1.pdf', 'I');

ob_end_flush(); 

解决方案


You do not need to set the header to UTF-8 but your editor have to be configured to use UTF-8. To verify that this is the issue, open the PHP file in e.g. Notepad++, click on "Encoding" and check the current encoding. You may convert it to UTF-8 (without BOM!!) in the same step and try again.



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.phpheidong.com/blog/article/476834/18e9c3a9bdb6c9fc9765/

来源:php黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

3 0
收藏该文
已收藏

评论内容:(最多支持255个字符)