icepdf icon indicating copy to clipboard operation
icepdf copied to clipboard

GH-272 Improves annotation summary

Open gtache opened this issue 2 years ago • 10 comments

Closes #272
No actual implementation of import/export is available to avoid adding dependencies to the project just for this function.
Need to review / refactor this code given that it was developed 3 years ago.

gtache avatar May 17 '23 08:05 gtache

Do you think it would be possible to refactor the implementation to use RandomAccessFile instead of the wrapper FileSeekableStream?

pcorless avatar Jul 26 '23 04:07 pcorless

scrubber_annots.pdf Here's a very wild test file, lot of annotation and not very well formed which can cause problems with new annoation work.

pcorless avatar Jul 26 '23 04:07 pcorless

I have a bit more testing to do but will try and get this in this week.

pcorless avatar Nov 13 '23 05:11 pcorless

I replaced FileSeekableInputStream with BufferedInputStream, it should work without problems.

gtache avatar Jan 29 '24 16:01 gtache

Thanks. I was just testing with the file I posted above and I get a null pointer out the yCoordinates map in SummaryController. Is this still a draft pr?

pcorless avatar Feb 01 '24 05:02 pcorless

I'll fix the NPE and the conflicts and then we should be good to remove the draft status.

gtache avatar Jun 12 '24 06:06 gtache

Seeing a few more stack traces when opening files with annotations.

SEVERE: Error getting /home/pcorless/dev/pdf-qa/annotations/annots/Invoice_text_box. java.nio.file.NoSuchFileException: /home/pcorless/dev/pdf-qa/annotations/annots/Invoice_text_box. at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219) at java.base/java.nio.file.Files.newByteChannel(Files.java:371) at java.base/java.nio.file.Files.newByteChannel(Files.java:422) at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420) at java.base/java.nio.file.Files.newInputStream(Files.java:156) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController.getDefaultSummaryInputStream(SummaryController.java:540) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController.tryImportSummaryFile(SummaryController.java:511) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController.refreshDocumentInstance(SummaryController.java:507) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryFrame.refreshDocumentInstance(AnnotationSummaryFrame.java:75) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.showAnnotationPreviewWindow(SwingController.java:4255) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.actionPerformed(SwingController.java:5048) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6635) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342) at java.desktop/java.awt.Component.processEvent(Component.java:6400) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843) 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)

pcorless avatar Jun 13 '24 03:06 pcorless

Jun. 12, 2024 9:10:43 P.M. org.icepdf.ri.common.SwingController openDocument FINE: Error opening document. java.lang.NullPointerException at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.resetComponentColors(AnnotationSummaryBox.java:158) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.buildGUI(PopupAnnotationComponent.java:397) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.(PopupAnnotationComponent.java:141) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.(AnnotationSummaryBox.java:66) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.createSummaryBox(ColorLabelPanel.java:115) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.addAnnotation(ColorLabelPanel.java:94) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.addAnnotation(ColorLabelPanel.java:143) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController$PropertiesListener.propertyChange(SummaryController.java:1179) at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:341) at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333) at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:266) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.DocumentViewControllerImpl.firePropertyChange(DocumentViewControllerImpl.java:1301) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.DocumentViewControllerImpl.addNewAnnotation(DocumentViewControllerImpl.java:1336) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.MarkupAnnotationComponent.createPopupAnnotationComponent(MarkupAnnotationComponent.java:171) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.MarkupAnnotationComponent.getPopupAnnotationComponent(MarkupAnnotationComponent.java:108) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.PageViewComponentImpl.initializeAnnotationsComponent(PageViewComponentImpl.java:592) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.PageViewComponentImpl.getComponentFor(PageViewComponentImpl.java:239) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.findAnnotationComponent(PopupAnnotationComponent.java:1081) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.getAnnotationParentComponent(PopupAnnotationComponent.java:520) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.getAnnotationComponent(AnnotationSummaryBox.java:244) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.getColor(AnnotationSummaryBox.java:196) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.resetComponentColors(AnnotationSummaryBox.java:157) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.buildGUI(PopupAnnotationComponent.java:397) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.PopupAnnotationComponent.(PopupAnnotationComponent.java:141) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryBox.(AnnotationSummaryBox.java:66) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.createSummaryBox(ColorLabelPanel.java:115) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.addAnnotation(ColorLabelPanel.java:94) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.colorpanel.ColorLabelPanel.addAnnotation(ColorLabelPanel.java:143) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.mainpanel.SummaryController.refreshDocumentInstance(SummaryController.java:496) at org.icepdf.ri.viewer/org.icepdf.ri.common.views.annotations.summary.AnnotationSummaryFrame.refreshDocumentInstance(AnnotationSummaryFrame.java:75) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.commonNewDocumentHandling(SwingController.java:3023) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.openDocument(SwingController.java:2564) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.openFileInSomeViewer(SwingController.java:2401) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.openFile(SwingController.java:2382) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.openFile(SwingController.java:2317) at org.icepdf.ri.viewer/org.icepdf.ri.common.SwingController.actionPerformed(SwingController.java:4888) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:369) at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:349) at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Actions.actionPerformed(BasicMenuItemUI.java:975) at java.desktop/javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1810) at java.desktop/javax.swing.JComponent.processKeyBinding(JComponent.java:2900) at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:699) at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706) at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706) at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706) at java.desktop/javax.swing.JMenuBar.processBindingForKeyStrokeRecursive(JMenuBar.java:706) at java.desktop/javax.swing.JMenuBar.processKeyBinding(JMenuBar.java:677) at java.desktop/javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:311) at java.desktop/javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:297) at java.desktop/javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2993) at java.desktop/javax.swing.JComponent.processKeyBindings(JComponent.java:2985) at java.desktop/javax.swing.JComponent.processKeyEvent(JComponent.java:2862) at java.desktop/java.awt.Component.processEvent(Component.java:6412) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843) at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1950) at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:870) at java.desktop/java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1139) at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:1009) at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:835) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4892) 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:4843) 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)

pcorless avatar Jun 13 '24 03:06 pcorless

Everything should work now, I didn't think about testing the case when there are no defined labeled colors.

gtache avatar Jun 13 '24 12:06 gtache

Getting there. I was doing some testing tonight and I think I found a dispose issue with the summary windows ore maybe a memory leak, not sure exactly. Here are steps to reproduce. Reopen issue

  1. open scrubber_annots.pdf
  2. sroll through the document, all pages,
  3. open the annotation summary window and close it.
  4. close the document
  5. open the document, crash dialog should appear.

Variation, might be slightly different issue related to page popups potentially not being created yet.

  1. open scrubber in a one page view.
  2. open the preview window, error dialog should show.

pcorless avatar Jun 18 '24 04:06 pcorless