Grails / RenderPdf 阿拉伯字符
我们有一个 grails 应用程序,在其中使用 渲染插件< /a> 以 .pdf 格式呈现内容。这对于英语来说一切正常,但不幸的是对于阿拉伯语(我们必须渲染)所有字符似乎都“损坏”。那里有一些数字和空格...
渲染插件使用 IText,我已经尝试过该方法:(
...
def renderer = new ITextRenderer()
FontResolver resolver = renderer.getFontResolver()
renderer.getFontResolver().addFont("/usr/share/fonts/truetype/ttf-arabeyes/ae_AlArabiya.ttf", BaseFont.EMBEDDED)
...
此处使用的字体只是一个示例),但无论如何,它都不起作用。
有人对此类问题有经验吗?
先感谢您!
We have a grails app, in which we are using the Render Plugin to render content in .pdf. It all works fine for English, but unfortunately for Arabic (which we must render) all the charactes seem "broken". Some numbers and spaces there...
The render plugin uses IText, and I have tried the approach with:
...
def renderer = new ITextRenderer()
FontResolver resolver = renderer.getFontResolver()
renderer.getFontResolver().addFont("/usr/share/fonts/truetype/ttf-arabeyes/ae_AlArabiya.ttf", BaseFont.EMBEDDED)
...
(the font used here is just an example), but in any case, it doesn't work.
Anybody any experience with this kind of issue?
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iText 中字体的默认编码是 WinAnsiEncoding,又称为代码页 1252。您需要指定包含所需字符的编码...
是的。 Google Code 为您正在使用的 addFont 生成了这段代码:
IDENTITY_H 可让您处理给定字体中的所有字形。我总是推荐它,尽管有一个小缺点。使用 IDENTITY_H 强制字体成为 iText 中的嵌入子集,没有办法绕过它。
The default encoding for fonts in iText is WinAnsiEncoding, AKA Code Page 1252. You need to specify an encoding that contains the characters you want...
Yep. Google Code produced this bit of code for the addFont you're using:
IDENTITY_H lets you address all the glyphs in a given font. I always recommend it, though there is a small drawback. Using IDENTITY_H forces the font to be an embedded subset in iText, no way around it.