Trying to create an external graphics using a PNG file does not works if you want to use JIMI instead JAI. Location: class::org.apache.fop.image.FopImageFactory method::getGenericImageClassName You catch an Exception when configuring m_genericImageClassName field. If you have configured JIMI in your classpath instead JAI it throws an Error: java.lang.NoClassDefFoundError: javax/media/jai/PlanarImage at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at org.apache.fop.image.FopImageFactory.getGenericImageClassName (FopImageFactory.java:236) at org.apache.fop.image.FopImageFactory.Make(FopImageFactory.java:163) ... ... In this scenario you cannot use FOP to render a PNG file. To solve this BUG you must catch Throwable instead Exception. A workaround is to set m_genericImageClassName to "org.apache.fop.image.JimiImage" via java.lang.reflect package before you call FOP. Bye. Thanks.
*** Bug 26847 has been marked as a duplicate of this bug. ***
Solution: private static String getGenericImageClassName() { if (m_genericImageClassName == null) { try { Class.forName("org.apache.fop.image.JAIImage"); m_genericImageClassName = "org.apache.fop.image.JAIImage"; } catch (Throwable ex) { /* on any exception assume Jai is not present and use Jimi instead */ m_genericImageClassName = "org.apache.fop.image.JimiImage"; } } return m_genericImageClassName; } Workaround: public static String checkFOP() { try { FopImageFactory.Make(PDFGenerator.class.getResource("blank.png"); return "png"; } catch (Throwable t) { try { // trying to set by hand Bug#: 26848 from FOP Class clazz = Class.forName ("org.apache.fop.image.FopImageFactory"); java.lang.reflect.Field field = clazz.getDeclaredField ("m_genericImageClassName"); field.setAccessible(true); field.set(null, "org.apache.fop.image.JimiImage"); FopImageFactory.Make(PDFGenerator.class.getResource ("blank.png"); return "png"; } catch (Throwable _t) { return "jpeg"; } } }
jimi is no longer supported
batch transition resolved+wontfix to closed+wontfix
batch transition resolved+wontfix to closed+wontfix; if you believe this remains a bug and can demonstrate it with appropriate input FO file and output PDF file (as applicable), then you may reopen