0

Had to cover a subclass of PDFView with an NSView to draw lines and texts, as PDFPage or PDFAnnotation don't seem to work at all. Successfully added the subview, showed a random text, but the problem is when I tried to scroll, only the underlining PDFView is scrolling, its subview (NSView) is standing still. Codes are as following: (m_markingView is NSView, m_drawing is PDFView)

m_markingView = [[CLMarkingView alloc] initWithFrame:m_drawing.bounds];
[m_drawing addSubview:m_markingView];
[m_drawing setNeedsDisplay:YES];

Anyone has any idea? Many thanks! (PS: PDFPage and PDFAnnotation work only at the start of the page, when you scroll the PDFView, all the lines and annotations will go away without ever coming back.)

  • Does this answer your question? [How do I draw something on a PDF in Swift?](https://stackoverflow.com/questions/41370101/how-do-i-draw-something-on-a-pdf-in-swift) – Willeke Feb 19 '22 at 11:32
  • Similar but his method is excessively time consuming, I need something happens in real time, can't afford redraw the whole page constantly. Thank you for your kind advice, it did help in some way, at least broadened my thoughts. – Young Shway Feb 19 '22 at 22:44
  • If you don't mind a hacky solution then inspect the runtime view hierarchy of the `PDFView` and insert your view where you want. – Willeke Feb 20 '22 at 12:14

0 Answers0