User 041aab2e15
15-12-2015 11:48:26
We were using Jchem version 6.1 for one of our product. We ran into an issue with pdf generation
logic while trying to upgrade to Jchem version 15.3.30. We use itext version 2.1.7 for pdf generation. When attempting to render multiple molecules
with same Molprinter instance, we see a NullPointerException. We don’t see this
issue when we use Jchem version 6.1. Creating a new Molprinter instance seem to the solve problem. Is
this an expected behavior or are we missing something?
Attaching a sample code (MolPrinterTestUsingSameInstance.
java) that shows the problem. The
following are instructions to execute the sample code.
Using JChem version 6.1
javac -cp
guava-15.0.jar:itext-rtf-2.1.7.jar:itext-2.1.7.jar:jchem-6.1.3.jar:rt.jar:. MolPrinterTestUsingSameInstance.java
java -cp
guava-15.0.jar:itext-rtf-2.1.7.jar:itext-2.1.7.jar:jchem-6.1.3.jar:rt.jar:. MolPrinterTestUsingSameInstance
Ouptut: test.pdf has the structures rendered properly
Using JChem version 15.3.30
javac -cp guava-15.0.jar:itext-rtf-2.1.7.jar:itext-2.1.7.jar:jchem-15.3.30.0.jar:rt.jar:. MolPrinterTestUsingSameInstance.java
java -cp
guava-15.0.jar:itext-rtf-2.1.7.jar:itext-2.1.7.jar:jchem-15.3.30.0.jar:rt.jar:. MolPrinterTestUsingSameInstance
Output:
java.lang.NullPointerException
at
com.lowagie.text.pdf.PdfGraphics2D.getFontMetrics(Unknown Source)
at
chemaxon.marvin.paint.internal.util.FontUtil.getFontMetrics(FontUtil.java:27)
at
chemaxon.marvin.paint.internal.fontsettings.AbstractFontSettings.getHeight(AbstractFontSettings.java:198)
at
chemaxon.marvin.paint.internal.AbstractTeXGraphics.getTextBounds(AbstractTeXGraphics.java:144)
…
at
chemaxon.marvin.paint.internal.MolPainter.setBoundsFor(MolPainter.java:2365)
at
chemaxon.marvin.MolPrinter.setMol(MolPrinter.java:1319)