ICEpdf
  1. ICEpdf
  2. PDF-964

NullPointerException at Annotation.init

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.2
    • Fix Version/s: 6.0.2_P01, 6.1
    • Component/s: Core/Rendering
    • Labels:
      None
    • Environment:
      ICEpdf Pro 6

      Description

      When rendering the provided PDF in ICEpdf 6.0.2 the following NPE is thrown and prevents the content from rendering. This isn't an issue with the 5.1.2 release.

      WARNING: Error initiating page: 0
      java.lang.NullPointerException
      at org.icepdf.core.pobjects.annotations.Annotation.init(Annotation.java:743)
      at org.icepdf.core.pobjects.annotations.MarkupAnnotation.init(MarkupAnnotation.java:172)
      at org.icepdf.core.pobjects.annotations.TextAnnotation.init(TextAnnotation.java:123)
      at org.icepdf.core.pobjects.Page.initPageAnnotations(Page.java:299)
      at org.icepdf.core.pobjects.Page.init(Page.java:341)
      at org.icepdf.ri.common.views.PageViewComponentImpl$PageInitializer.run(PageViewComponentImpl.java:1169)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:745)

        Activity

        Hide
        Jeff Burja added a comment -

        This NPE seems to be occurring when we only process documents created by

        /CreationDate(D:20160119112538-05'00')
        /Title(Created with ACI PDF Generator)
        /Creator(PDFsharp 1.32.2608-g (www.pdfsharp.net))
        /Producer(PDFsharp 1.32.2608-g (www.pdfsharp.net))

        I'm not sure if these documents appear to even have any annotations but they are listed (/Annots[5 0 R]). It appears to be a TextAnnotation (

        {T=Letter of Transmittal - 1, Type=Annot, Subtype=Text, Name=Comment, M=D:20160117124040-05'00', NM=ee9f9211-ba8b-43b0-88b3-792585c520af}

        ).

        Although this is probably not the solution, I'm able to get around this issue by updating org.icepdf.core.pobjects.Page. In this conditional, I'm updating a to be null so it doesn't get initialized.

        Page.java
                        // set the object reference, so we can save the state correct
                        // and update any references accordingly. 
                        if (ref != null && a != null) {
                            a.setPObjectReference(ref);
                            a.init();
                        }
        

        Here I'm just updating paintAnnotation to false so it doesn't bother painting it since it wasn't initialized.

        Page.java
        public void paint(Graphics g, int renderHintType, final int boundary,
                              float userRotation, float userZoom,
                              boolean paintAnnotations, boolean paintSearchHighlight) {
        

        The right solution is to fix loading the annotation itself. I don't think we typically have annotations displayed in our documents so I'm wondering if for an easy fix would be to turn that functionality off with a System property?

        Show
        Jeff Burja added a comment - This NPE seems to be occurring when we only process documents created by /CreationDate(D:20160119112538-05'00') /Title(Created with ACI PDF Generator) /Creator(PDFsharp 1.32.2608-g (www.pdfsharp.net)) /Producer(PDFsharp 1.32.2608-g (www.pdfsharp.net)) I'm not sure if these documents appear to even have any annotations but they are listed (/Annots [5 0 R] ). It appears to be a TextAnnotation ( {T=Letter of Transmittal - 1, Type=Annot, Subtype=Text, Name=Comment, M=D:20160117124040-05'00', NM=ee9f9211-ba8b-43b0-88b3-792585c520af} ). Although this is probably not the solution, I'm able to get around this issue by updating org.icepdf.core.pobjects.Page. In this conditional, I'm updating a to be null so it doesn't get initialized. Page.java // set the object reference, so we can save the state correct // and update any references accordingly. if (ref != null && a != null ) { a.setPObjectReference(ref); a.init(); } Here I'm just updating paintAnnotation to false so it doesn't bother painting it since it wasn't initialized. Page.java public void paint(Graphics g, int renderHintType, final int boundary, float userRotation, float userZoom, boolean paintAnnotations, boolean paintSearchHighlight) { The right solution is to fix loading the annotation itself. I don't think we typically have annotations displayed in our documents so I'm wondering if for an easy fix would be to turn that functionality off with a System property?
        Hide
        Patrick Corless added a comment -

        For some reason each page has a partial annotation as mentioned in the above comments. This must be some bug or place holder that the PDF encoder is putting into each page of the document. The Annotation is missing a couple required dictionary entries which is causing the rendering process to fail. This is the first time we have see this type of encoding error.

        In this particular case we are missing the /rect entry which defines where the annotation should be drawn on the page. Rather then taking the time to build a fake /rect tangle off screen I've opted for for throwing a Illegal State exception so we can handle ignoring the annotation but continuing on with processing any proper annotatins.

        Show
        Patrick Corless added a comment - For some reason each page has a partial annotation as mentioned in the above comments. This must be some bug or place holder that the PDF encoder is putting into each page of the document. The Annotation is missing a couple required dictionary entries which is causing the rendering process to fail. This is the first time we have see this type of encoding error. In this particular case we are missing the /rect entry which defines where the annotation should be drawn on the page. Rather then taking the time to build a fake /rect tangle off screen I've opted for for throwing a Illegal State exception so we can handle ignoring the annotation but continuing on with processing any proper annotatins.
        Hide
        Patrick Corless added a comment -

        Marking as fixed.

        Show
        Patrick Corless added a comment - Marking as fixed.

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Arran Mccullough
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: