9 Replies
      Latest reply on Aug 26, 2017 6:09 AM by Amitabh
      Samuco Level 1 Level 1 (0 points)

        The only way to redraw an annotation in Sierra seems to be to close and reopen the document (while previously a simple setNeedsDisplayInRect would suffice). Is this a bug or intentional crippling of PDFKit?


        Also, why have the classes / methods related to annotations been deprecated within the PDFKit framework? Specifically, most of the methods of PDFAnnotation and the following classes. No reason / alternative seems to be provided in the docs.














        • Re: PDFKit Annotations are broken
          Germanotto Level 1 Level 1 (0 points)

          I believe this is a bug (zooming in and out makes the annotations re-appear for me).


          This still happens in the Sierra official release. I suggest everyone who encounters this to submit a bug report at https://bugreport.apple.com

          • Re: PDFKit Annotations are broken
            equivocates Level 1 Level 1 (0 points)

            Does anyone know why those PDFAnnotation types have been deprecated? And what we can use instead?

            • Re: PDFKit Annotations are broken
              Aderstedt Level 1 Level 1 (0 points)

              I've submitted several bugs against PDFKit, which as I understand it has received a complete rewrite for 10.12. There are so many problems with it that I wish they'd roll back to the 10.11 version for now and aim for 10.13 instead:


              - In some cases I get two copies of each annotation, slightly offset from each other. The two copies may have different font colors (?).

              - Changes to string values to annotations don't update the view.


              A common work-around for most issues is (for me anyway) to set the PDFView's document to nil, call -[PDFView display], then set it back and call -[PDFView setNeedsDisplay]. This does not help for all the bugs when a user interacts with a text annotation widget by clicking on it.

              • Re: PDFKit Annotations are broken
                michaelallenkelso Level 1 Level 1 (0 points)

                Having the same problem and found this problem discussed on stackoverflow.


                No luck with any of the following PDFKit methods:

                for pageIndex in 0...pdf.pageCount - 1 { 
                     let page = pdf.page(at: pageIndex)! 
                     previewView.annotationsChanged(on: page) 


                or any of the following NSView methods:

                previewView.needsDisplay = true 
                previewView.needsLayout = true 
                previewView.documentView?.needsDisplay = true 


                I've tried scrolling the PDFView with code too but it hasn't been a reliable way of sneaking a refresh, and in general shouldn't be the way to signal that annotations have been added anyway.

                • Re: PDFKit Annotations are broken
                  kingrichardthethird Level 1 Level 1 (0 points)

                  PDFKit in Sierra has been a nightmare. I've just spent a day reworking my code to use the new API (or lack of one!) only to find creating annotations just doesn't seem to work, and a commenter here says that the mass deprecation was a mistake? This is after I had to hack the **** out of things to even run at all on 10.12's initial release. It's enough to make you loose any faith in Apple - this rework of PDFKit (which worked just fine before hand) was clearly released far too early.

                  • Re: PDFKit Annotations are broken
                    Amitabh Level 1 Level 1 (0 points)

                    Did this issue get resolved? Any update since the latest release of PDFKit beta 6?