如何使用iText在PDF中嵌入Helvetica字体? [英] How to embed Helvetica font in PDF using iText?

查看:804
本文介绍了如何使用iText在PDF中嵌入Helvetica字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用iText在PDF中嵌入Helvetica字体?



以下行不通:

  BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA,
BaseFont.CP1252,BaseFont.EMBEDDED);
Font font = new Font(helvetica,20,Font.BOLD);

即返回false:

< pre $ font.getBaseFont()。isEmbedded()

嵌入如果我将自己的TrueType文件作为参数提供给createFont()方法,那么这个方法就可以工作了。解析方法

是的,嵌入定义的字体不会
工作不能工作
iText,为了嵌入字体,必须有访问字体的资源。所定义的字体由PDF阅读器提供,因此在PDF创建过程中您的图书馆不可用。
另外,每个PDF阅读器都必须提供这种字体,这种字体的授权方法的自由选择。除了在该阅读器中显示PDF文件之外,他们的许可证可以禁止任何最终用法。


How to embed Helvetica font in PDF using iText?

Following does not work:

BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA,
        BaseFont.CP1252, BaseFont.EMBEDDED);
Font font = new Font(helvetica, 20, Font.BOLD);

That is, this will return false:

font.getBaseFont().isEmbedded()

Embedding works if I provide the TrueType file myself as a parameter to createFont() method.

解决方案

Yes, embedding of defined fonts will not work.
It cannot work.
iText, in order to embed font, must have the access to font resource. The defined fonts are provided by PDF reader and therefore are not available to your library during PDF creating process.

What is more, each PDF reader must provide this fonts, but have freedom of choice of licencing method for this fonts. Their licence can forbid any usage for final usage except the displaying of PDF files in that reader.

这篇关于如何使用iText在PDF中嵌入Helvetica字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆