Add pdf annotation with PDF Kit in OS 10.12

2020-03-26 08:36发布

问题:

Now the latest os10.12 operating system, PDF annotation can be displayed, but now I still have a problem, I recorded coordinate information in PDFView ->mouseDragged before, and then automatically will invoke the PDFView->drawPage function, this function I will draw the NSBezierPath curve to determine the dynamic annotation bounds. but now in the process of mouseDragged has not been call the drawPage:toContext function. So I can't see the dynamic curve of adding annotation. I use the refresh method is still not invoke drawPage:toContext, only open pdf and scroll view pdf kit will invoke drawPage:toContext. I would like to know how to call this function. Thank you very much for your help.

回答1:

PDFKit sems to be in bit of a pickle at the moment. https://forums.developer.apple.com/thread/60440

I have had some success using drawPage:inContext: (which is a private method covered by drawPage:toContext:). Try adding drawPage:inContext: to a class extension (ARC requires all selectors to be defined) and see if it gets called.