简体   繁体   中英

Convert an XML file to PDF using XSLT and XSL-FO/FOP

I'm trying to convert an XML file to a PDF file using XSL-FO, I found the code in this example:

http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleXML2PDF.java?view=markup

but I receive this Exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlgraphics/image/loader/impl/ImageRawPNG
at org.apache.fop.render.pdf.PDFImageHandlerRawPNG.getSupportedImageClass(PDFImageHandlerRawPNG.java:51)
at org.apache.fop.render.ImageHandlerRegistry.addHandler(ImageHandlerRegistry.java:97)
at org.apache.fop.render.ImageHandlerRegistry.discoverHandlers(ImageHandlerRegistry.java:169)
at org.apache.fop.render.ImageHandlerRegistry.<init>(ImageHandlerRegistry.java:64)
at org.apache.fop.apps.FopFactory.<init>(FopFactory.java:168)
at org.apache.fop.apps.FopFactory.newInstance(FopFactory.java:177)
at searchManagement.export.PdfExporter.main(PdfExporter.java:77)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlgraphics.image.loader.impl.ImageRawPNG
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 7 more

Do you have some advices?

Thanks!

This error means that one of the classes you are using is trying to use the class org/apache/xmlgraphics/image/loader/impl/ImageRawPNG but can't find it.

What you need to do, is find the jar that contains that class and add it to the classpath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM