DOMPDF 西里尔字母问题
我正在使用 DOMPDF 库创建 PDF 格式的发票。 该文档可以是法语、俄语或英语,但我在打印俄语字符时遇到问题。
首先,我尝试使用UTF-8编码,并将meta
标签放置在要转换的HTML页面的头部:
但这没有用。
然后我将这个 meta
标签插入到 BODY
标签中,它帮助解决了法语字符的问题。
但俄语字符仍然不起作用。 我也尝试过将俄语字符转换为 HTML 实体,但这也不起作用。
我使用 R&OS CPDF 类,而不是 PDFLib 作为后端。
有人可以帮忙吗?
I am using the DOMPDF library to create an invoice in PDF. This document can be in French, Russian or English, but I am having trouble printing Russian characters.
First, I tried to use UTF-8 encoding and placed the meta
tag in the head of the HTML page to be converted:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
But that didn't work.
Then I inserted this meta
tag inside the BODY
tag, and it helped solve the problem with French characters.
But Russian characters still don't work. I have also tried to convert Russian characters into HTML entities, but that too does not work.
I use R&OS CPDF class, not PDFLib as a backend.
Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您使用 DejaVu 字体,您可以看到西里尔字符
DOMPDF 默认包含 DejaVu 字体
您还可以在 dompdf_config.inc.php 中设置默认字体的更改 def
if you will use DejaVu font you can see cyrillic characters
DOMPDF include DejaVu font be default
You can also set change def for font by default in dompdf_config.inc.php
问题在于 dompdf 默认使用的字体(即它不包含所有 unicode 字符,目前已超过 5000 个)。 通常 arialuni.ttf 就是您所需要的。 您可以在 http://chernev.ru/dompdf.rar {broken link} 下载本地化的俄语版本
更新的链接:https://code.google.com/p /ipwn/downloads/detail?name=arialuni.ttf
Problem is with fonts default dompdf uses (that is it doesn't have all unicode characters, whick are by now over 5000). Usually arialuni.ttf is what you need. You can download localized russian version at http://chernev.ru/dompdf.rar {broken link}
Updated link: https://code.google.com/p/ipwn/downloads/detail?name=arialuni.ttf
在您的 html 中,使用以下样式:
In your html, use this style :
下载 arialuni.ttf
在dompdf目录下运行php load_font.php 'Arial' arialuni.ttf,将字体设置为arial
有用 ;)
Download arialuni.ttf
Run php load_font.php 'Arial' arialuni.ttf in dompdf directory, set font to arial
It works ;)
如果其他答案都没有帮助,
将 Dompdf 升级到版本 7.0.0 对我有帮助。
这是我要生成的代码:
If none of the other answers help,
upgrading Dompdf to version 7.0.0 helped me.
Here is my code to generate:
对我来说,上述 4 个步骤并没有解决问题。
除此之外,dompdf 将创建的 pdf 转换为 ANSI (ISO)
您需要在选项页面上禁用此功能
http://domain.com/admin/settings/print/pdf
勾选使用复选框dompdf 的 Unicode 模式。 这将强制以 UTF-8/Unicode 创建文件。
请注意,默认情况下,Web 设置会覆盖 dompdf_config.inc.php 中的设置。
For me the 4 steps above didn't resolve the issue.
Besides that, dompdf converts created pdf to ANSI (ISO)
You need to disable this on the options page
http://domain.com/admin/settings/print/pdf
Tick the checkbox Use dompdf's Unicode Mode. This will force to create files in UTF-8/Unicode.
Please note that web settings override settings in dompdf_config.inc.php by default.
注意到问题可能出在 css-reset 使用中,特别是
字体:继承;
Noted that problem could be in css-reset usage, particularly
font:inherit;