Skip to main content
Skip table of contents

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

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 it misses the Adobe Font Metrics (.afm) files. 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.

Click Why do I get a message saying 1.not.found.as.a.resource? if you want to see how to answer this question in iText 5.

JavaScript errors detected

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

If this problem persists, please contact our support.