PDFKit Annotations are broken

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. 

PDFAnnotationButtonWidget

PDFAnnotationChoiceWidget

PDFAnnotationCircle

PDFAnnotationFreeText

PDFAnnotationInk

PDFAnnotationLine

PDFAnnotationLink

PDFAnnotationMarkup

PDFAnnotationPopup

PDFAnnotationSquare

PDFAnnotationStamp

PDFAnnotationText

PDFAnnotationTextWidget

Replies

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

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

I asked about this at WWDC and got the response that the deprecations was a mistake. I would have expected this to be fixed by now…😢

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.

The PDFannotations certianly are buggier on sierra. For example, PDFAnnotationFreeText.setFontColor does not set font color.

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


No luck with any of the following PDFKit methods:

previewView.layoutDocumentView() 

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 
previewView.updateLayer()


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.

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.

I agree, PDFKit has become a nightmare in 10.12.


In the other well-known bugs:


- PDFViewDocumentChanged notification is not posted

- PDFView.allowsDragging = true has no effect => not possible to drop a PDF on the view


... please Apple, do something about it.

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