Reportlab:启用加密的亚洲字体不起作用
我在我的reportlab生成的pdf文件中使用亚洲字体(中文简体/繁体、日语和韩语)已经有一段时间了,没有出现任何问题。然而最近我们决定启用这样的加密选项:
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.cidfonts import UnicodeCIDFont
pdfmetrics.registerFont(UnicodeCIDFont("STSong-Light"))
enc = pdfencrypt.StandardEncryption(
"", canPrint=1, canModify=0, canCopy=0, canAnnotate=0
)
self._Report = SimpleDocTemplate(
save_file,
topmargin=0.75*inch, bottommargin=0.75*inch,
rightmargin=0.70*inch, leftmargin=0.70*inch,
showBoundary=0,
author="xxx",
title="xxx",
subject=xxx",
encrypt=enc
)
对于非亚洲语言,加密按预期工作。当我们使用加密的亚洲字体时,adobe reader 无法读取 pdf。例如,对于简体中文,我们会从 Adobe Reader 中收到“无法找到字体“STSong-Light”的错误。
任何人都知道什么加密被破坏而无法正常工作吗?
I have been using Asian fonts (Chinese simplified/tradional, Japanese, and Korean) in my reportlab generated pdfs without issuse for a while now. However recently we have decided to enable the encryption options like this:
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.cidfonts import UnicodeCIDFont
pdfmetrics.registerFont(UnicodeCIDFont("STSong-Light"))
enc = pdfencrypt.StandardEncryption(
"", canPrint=1, canModify=0, canCopy=0, canAnnotate=0
)
self._Report = SimpleDocTemplate(
save_file,
topmargin=0.75*inch, bottommargin=0.75*inch,
rightmargin=0.70*inch, leftmargin=0.70*inch,
showBoundary=0,
author="xxx",
title="xxx",
subject=xxx",
encrypt=enc
)
For non Asian languages the encryption works as expected. When we use Asian fonts with encryption the pdf cannot be read by adobe reader. For example with simplified Chinese we get a "Cannot find the font "STSong-Light" error from Adobe Reader.
Anyone have any ideas on what encryption is breaking to not make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题。这可能无法解决您的问题。
但是,如果我将其指定为日语,
你可以通过安装
TTFont
来解决这个问题(在这个例子中它是IPA gothic),并设置字体。
所以,通过安装其他语言的字体,你可以解决这个问题
这不酷。
I had the same problem. This might not solve your problem.
But, If I specify it into Japanese,
you can solve it by installing
TTFont
(in this example it is IPA gothic),and set the font.
So, by installing another languages fonts, you can solve the problem though
this is not cool.