Skip to main content
Skip table of contents

Why do I get a message saying 1.not.found.as.a.resource?

Why am I getting this message?

What might cause

 

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

 

BaseFont.createFont(BaseFont.HELVETICA, 'Cp1252', BaseFont.NOT_EMBEDDED)
to start returning the following DocumentException?

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

 

Posted on StackOverflow on Jul 11, 2015 by John Renfrew

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:

  • 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.

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.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.