[
https://issues.apache.org/jira/browse/PDFBOX-4428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16745073#comment-16745073
]
Nico Prenzel commented on PDFBOX-4428:
--------------------------------------
After some further research i've found a potential solution for the font
loading:
It seems to be that the IBM Lotus JVM has a strange classloader implementation.
Nonetheless with
{code:java}
afmStream = this.getClass().getResourceAsStream(resourceName);{code}
the font resource file could be loaded fine.
Attached you'll find my attempts for loading the fonts:
{code:java}
public void NotesMain() {
String afmName = "Courier-Bold";
String resourceName = "org/apache/pdfbox/resources/afm/" + afmName +
".afm";
InputStream afmStream = null;
URL url = null;
// URL url = getClass().getClassLoader().getResource(resourceName);
// URL url = getClass().getResource(resourceName);
//URL url =
PDType1Font.class.getClassLoader().getResource(resourceName);
afmStream = this.getClass().getResourceAsStream(resourceName);
if (url != null) {
System.out.println("url.toString():" + url.toString());
try {
afmStream = url.openStream();
} catch (IOException e) {
// TODO Automatisch erstellter Catch-Block
e.printStackTrace();
}
}
try {
System.out.println("afmStream:" + afmStream.toString());
AFMParser parser = new AFMParser(afmStream);
FontMetrics metric = parser.parse(true);
System.out.println("parser.toString():" + parser.toString());
System.out.println("metric.toString():" + metric.toString());
} catch (IOException e) {
// TODO Automatisch erstellter Catch-Block
e.printStackTrace();
} finally {
try {
afmStream.close();
} catch (IOException e) {
// TODO Automatisch erstellter Catch-Block
e.printStackTrace();
}
}
}{code}
I'am not sure the above file loading works in all situations.
> pdfbox called by Lotus Notes/Domino agent can't load afm fonts
> --------------------------------------------------------------
>
> Key: PDFBOX-4428
> URL: https://issues.apache.org/jira/browse/PDFBOX-4428
> Project: PDFBox
> Issue Type: Bug
> Components: FontBox, PDModel
> Affects Versions: 2.0.13
> Environment: Win32/Linux
> Reporter: Nico Prenzel
> Priority: Minor
>
> Within agent execution (java runtime) we get the follwoing errors loading the
> afm fonts.
> Any hints why this could occur?
> Exception in thread "AgentThread: JavaAgent"
> java.lang.ExceptionInInitializerError
> at java.lang.J9VMInternals.ensureError(J9VMInternals.java:146)
> at
> java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:135)
> at org.apache.pdfbox.pdmodel.font.PDFont.<init>(PDFont.java:91)
> at
> org.apache.pdfbox.pdmodel.font.PDSimpleFont.<init>(PDSimpleFont.java:64)
> at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:122)
> at
> org.apache.pdfbox.pdmodel.font.PDType1Font.<clinit>(PDType1Font.java:79)
> at JavaAgent.NotesMain(JavaAgent.java:87)
> at lotus.domino.AgentBase.runNotes(Unknown Source)
> at lotus.domino.NotesThread.run(Unknown Source)
> Caused by: java.lang.RuntimeException: java.io.IOException:
> org/apache/pdfbox/resources/afm/Courier-Bold.afm not found
> at
> org.apache.pdfbox.pdmodel.font.Standard14Fonts.<clinit>(Standard14Fonts.java:97)
> ... 7 more
> Caused by: java.io.IOException:
> org/apache/pdfbox/resources/afm/Courier-Bold.afm not found
> at
> org.apache.pdfbox.pdmodel.font.Standard14Fonts.addAFM(Standard14Fonts.java:134)
> at
> org.apache.pdfbox.pdmodel.font.Standard14Fonts.addAFM(Standard14Fonts.java:103)
> at
> org.apache.pdfbox.pdmodel.font.Standard14Fonts.<clinit>(Standard14Fonts.java:50)
> ... 7 more
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]