有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java PDFbox 2.0.20 new PagePane()引发RuntineeException

由于我已将PDFbox更新为最新版本(2.0.8->;2.0.20),因此在实例化PagePane类时出现运行时错误

我试图更改JDK版本,也从maven获取最新的依赖项,将我的项目切换到maven以消除依赖项

无论如何,我在执行这个原始代码段(在主void中运行)时出错:

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setSize(1000, 1000);
    File file = new File("/home/bujakowski/Pobrane/test.pdf");
    PDDocument doc;
    try {
        doc = PDDocument.load(file);

        JLabel lab = new JLabel();
        PagePane pp = new PagePane(doc, doc.getPage(0).getCOSObject(),new JLabel());
        f.add(pp.getPanel());
        f.setVisible(true);

    } catch (IOException ex) {
    }
}

我还尝试了不同的PDF版本——扫描图像、纯文本、混合内容、旧PDF版本和最新版本

我还看到错误可能来自PagePane jar中调用的BuffereImage。 我默认使用JDK 11

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NullPointerException at org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.done(PagePane.java:434) at java.desktop/javax.swing.SwingWorker$5.run(SwingWorker.java:750) at java.desktop/javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:847) at java.desktop/sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112) at java.desktop/javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:857) at java.desktop/javax.swing.Timer.fireActionPerformed(Timer.java:317) at java.desktop/javax.swing.Timer$DoPostEvent.run(Timer.java:249) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at java.desktop/javax.swing.SwingWorker.get(SwingWorker.java:613) at org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.done(PagePane.java:414) ... 19 more Caused by: java.lang.NullPointerException at org.apache.pdfbox.debugger.ui.RotationMenu.getRotationDegrees(RotationMenu.java:102) at org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.doInBackground(PagePane.java:391) at org.apache.pdfbox.debugger.pagepane.PagePane$RenderWorker.doInBackground(PagePane.java:384) at java.desktop/javax.swing.SwingWorker$1.call(SwingWorker.java:304) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.desktop/javax.swing.SwingWorker.run(SwingWorker.java:343) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.apache.pdfbox.debugger.pagepane.PagePane.ancestorAdded(PagePane.java:271) at java.desktop/javax.swing.AncestorNotifier.fireAncestorAdded(AncestorNotifier.java:86) at java.desktop/javax.swing.AncestorNotifier.componentShown(AncestorNotifier.java:193) at java.desktop/java.awt.Component.processComponentEvent(Component.java:6463) at java.desktop/java.awt.Component.processEvent(Component.java:6411) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Window.processEvent(Window.java:2049) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5007) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4839) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.apache.pdfbox.debugger.pagepane.PagePane.ancestorRemoved(PagePane.java:283) at java.desktop/javax.swing.AncestorNotifier.fireAncestorRemoved(AncestorNotifier.java:108) at java.desktop/javax.swing.AncestorNotifier.componentHidden(AncestorNotifier.java:208) at java.desktop/java.awt.AWTEventMulticaster.componentHidden(AWTEventMulticaster.java:197) at java.desktop/java.awt.AWTEventMulticaster.componentHidden(AWTEventMulticaster.java:197) at java.desktop/java.awt.Component.processComponentEvent(Component.java:6466) at java.desktop/java.awt.Component.processEvent(Component.java:6411) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Window.processEvent(Window.java:2049) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5007) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4839) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


共 (0) 个答案