如何检查字体是否可嵌入。
|
我正在使用itext创建PDf文档。由于许可限制,某些字体不能使用。
...
ExceptionConverter: com.lowagie.text.DocumentException: C:\\WINDOWS\\Fonts\\LucidaSansRegular.ttf cannot be embedded due to licensing restrictions.
at com.lowagie.text.pdf.TrueTypeFontUnicode.<init>(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at com.lowagie.text.pdf.DefaultFontMapper.awtToPdf(Unknown Source)
at com.lowagie.text.pdf.PdfGraphics2D.getCachedBaseFont(Unknown Source)
at com.lowagie.text.pdf.PdfGraphics2D.setFont(Unknown Source)
...
我正在考虑检查字体或PDF内容以检查这种情况。如何使用Java或itext检查字体是否可嵌入?
没有找到相关结果
已邀请:
1 个回复
闲窍
您可能真的可以成为硬核,并执行对Windows Apis的本地调用来获得相同的结果,但是我认为对于这样一个简单的任务,它的工作量太大。 做了一些研究,发现Java如何抛出此异常 可以在这里找到生成上述异常的代码。 http://kickjava.com/src/com/lowagie/text/pdf/TrueTypeFont.java.htm 行号367,368
要注意的有趣部分是条件
os_2是
的实例,请参见第174行 http://kickjava.com/src/com/lowagie/text/pdf/TrueTypeFont.java.htm 在Google中搜索WindowsMetrics,这就是我得到的。 这说明参数fsType包含有关是否可以嵌入字体的信息。 http://www.microsoft.com/typography/otspec/os2ver3.htm#fst itext中使用的WindowsMetrics的Java等效项 http://www.docjar.org/docs/api/com/lowagie/text/pdf/TrueTypeFont.WindowsMetrics.html