为什么在 PHP 中使用 FPDF 时亚洲 unicode 字符没有出现在 PDF 上?

发布于 2024-09-15 17:28:48 字数 358 浏览 1 评论 0原文

我正在使用 FPDF 创建 PDF 和 tFPDF 以允许使用 unicode 字符,例如中文、日文或韩文。

我正在使用 tFPDF 示例文件中的 ex.php。

我在 Hello World.txt 文件中添加了一些日语和中文字符,但这些字符没有显示,即使使用包含的默认 DejaVu 字体也是如此。

我需要做什么才能让其他字符(例如日语、中文、韩语)显示出来?

I am using FPDF to create a PDF and tFPDF to allow for unicode characters, such as Chinese, Japanese, or Korean.

I am using the ex.php that was in the tFPDF example files.

I added some Japanese and Chinese Characters to the Hello World.txt file, but those characters are not showing up, even in the default DejaVu font that was included.

What do I need to do to make other characters like Japanese, Chinese, Korean show up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

药祭#氼 2024-09-22 17:28:48

您正在使用的 API 需要为您尝试添加到文档中的 unicode 字符进行编码提供特定支持。这是通过这些字符的代码页/字符集来完成的。有许多不同的字符集可用于日语、中文和韩语字符,例如 Hangeul、GB2312、Chinese Big 5、Shift JIS 等。

您使用的 API 需要支持与您正在使用的文本相匹配的字符集试图添加。

看起来 FPDF 支持一些中文代码页,因为他们的论坛上有一些关于使用 GB2312 和中文 Big 5,但由于他们在主页上似乎没有提及 unicode,我的猜测是他们没有为其提供广泛的支持。

The API that you're using needs to provide specific support for encoding the unicode characters that you're trying to add to the document. This is done by way of a codepage / charset for those characters. There are a number of different charsets available for Japanese, Chinese and Korean characters such as Hangeul, GB2312, Chinese Big 5, Shift JIS, etc.

The API that you're using needs to support the charset that matches the text which you're trying to add.

It looks like FPDF supports some Chinese codepages since there's some info on their forum about adding text using GB2312 and Chinese Big 5, but as they don't appear to mention unicode on their main pages, my guess is that they don't provide extensive support for it.

遇到 2024-09-22 17:28:48

fpdf 有一个多字节版本,名为 mbfpdf (我想可以免费获得)。有了它和 PGOTHIC 字体,就可以显示亚洲字符。我自己使用这个类(mbfpdf)创建了一些pdf文件,效果很好。

There is a multi byte version of fpdf called mbfpdf (freely available I suppose). With that and the PGOTHIC font, it is possible to display Asian characters. I have used this class (mbfpdf) to create a few pdf files myself and it worked well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文