我正在尝试开发一个应用程序,它以 html 文件或 url 作为输入并呈现与 PDF 文件相同的内容。为此,我正在使用 yahp。我已经导入了yahp.jar
文件,但是我遇到了以下异常:
java.lang.ClassNotFoundException: org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.allcolor.yahp.converter.CClassLoader.findClass(CClassLoader.java:1495)
at org.allcolor.yahp.converter.CClassLoader.findClass(CClassLoader.java:1477)
at org.allcolor.yahp.converter.CClassLoader.loadClass(CClassLoader.java:2056)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.allcolor.yahp.converter.CYaHPConverter.getTransformer(CYaHPConverter.java:383)
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:246)
at HtmlToPDF.htmlToPdfFile(HtmlToPDF.java:74)
at HtmlToPDF.main(HtmlToPDF.java:52)
SEVERE: Error while getting transformer 'org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer' ! : org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer
org.allcolor.yahp.converter.IHtmlToPdfTransformer$CConvertException
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:255)
at HtmlToPDF.htmlToPdfFile(HtmlToPDF.java:74)Done
at HtmlToPDF.main(HtmlToPDF.java:52)
Caused by: java.lang.NullPointerException
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:247)
... 2 more
Destroying YAHP ClassLoader Tree
Exception in thread "AWT-Windows" java.lang.IllegalStateException: Shutdown in progress
at java.lang.ApplicationShutdownHooks.add(Unknown Source)
at java.lang.Runtime.addShutdownHook(Unknown Source)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)