为什么我会收到一条消息,提示1.not.found.as.a.resource? [英] Why do I get a message saying 1.not.found.as.a.resource?

查看:580
本文介绍了为什么我会收到一条消息,提示1.not.found.as.a.resource?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能导致的原因

new Font(Font.HELVETICA, 11f, Font.BOLD)

BaseFont.createFont(BaseFont.HELVETICA, 'Cp1252', BaseFont.NOT_EMBEDDED)

开始返回以下内容?

com.itextpdf.text.DocumentException: No message found for 1.not.found.as.resource

Max OSX 10.10上的

itext 5.5.6 jar on Max OSX 10.10

推荐答案

似乎您不是在使用罐头"罐子,而是创建了自己的罐子.那个自制的jar只包含Java类文件.它会丢失语言(.lng)和Adobe Font Metrics(.afm)文件之类的资源.

It seems that you are not using the "pre-canned" jar, but that you have created your own jar. That self-made jar only contains the Java class files. It misses resources such as the language (.lng) and the Adobe Font Metrics (.afm) files.

如果以上假设是错误的,那么至少这是正确的:

If the above assumption is wrong, then at least this is right:

  • key 替换为错误消息,而不是实际的错误消息,该错误消息存储在.lng文件:1.not.found.as.resource中.该键用于以您的操作系统语言查找实际的错误消息(支持英语,荷兰语和葡萄牙语;默认为英语).
  • 实际的错误消息(应该找到en.lng)应该是:未找到Helvetica作为资源" (1.not.found.as.resource中的1是一个占位符).此消息告诉您找不到文件Helvetica.afm.此文件包含Helvetica(常规)字体中每个字形的度量.没有这些指标,就无法创建正确的PDF.
  • Instead of the actual error message, you get the key to an error message that is stored in a .lng file: 1.not.found.as.resource. This key is used to find the actual error message in the language of your OS (English, Dutch and Portuguese are supported; the default is English).
  • The actual error message (should en.lng be found) would have been: "Helvetica not found as a resource" (the 1 in 1.not.found.as.resource is a placeholder). This message tells you that the file Helvetica.afm can't be found. This file contains the metrics of every glyph in the font Helvetica (regular). Without those metrics, you can't create a proper PDF.

这说明了会发生什么.您的问题没有足够的信息来解释为什么为什么.当将正确的jar与知道如何从jar中读取资源的JDK一起使用时,所有这些都不应该成为问题.您写了可能导致 ... 开始 返回以下内容" 的事实,表明它以前对您有用.想一想您在上次工作到第一次停止工作之间所做的更改(例如,更改操作系统,更改JVM等).这可能是罪魁祸首.

This explains what happens. Your question doesn't contain sufficient information to explain why it happens. All of this shouldn't be a problem when using the correct jar with a JDK that knows how to read resources from a jar. The fact that you write "What might cause ... to start returning the following" indicates that it has worked for you before. Think of what you have changed between the last time it worked and the first time it stopped working (e.g. changing the OS, changing the JVM,...). That will probably be the culprit.

这篇关于为什么我会收到一条消息,提示1.not.found.as.a.resource?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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