如何处理FPDF中的特殊字符

编程入门 行业动态 更新时间:2024-10-23 11:31:29
本文介绍了如何处理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.

www.mpdf1/mpdf/index.php

更多推荐

如何处理FPDF中的特殊字符

本文发布于:2023-10-29 09:57:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539395.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何处理   特殊字符   FPDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!