Hello I would like to place a PDFAnnotation onto a PDF page in a place where the user clicked with the mouse. Position for PDFAnnotations is specified using "page coordinates". Mouse position - using global coordinates, which can be translated into PDFView coordinates. However, I can't figure out how to translate view coordinates into page coordinates correctly. Here's what I am doing:
NSPoint locationInView = [self convertPoint:[theEvent locationInWindow] fromView:[[self window] contentView]]; NSPoint locationOnPage = [self convertPoint:locationInView fromView:self]; float scaleFactor = 1/[self scaleFactor]; locationOnPage = NSMakePoint((locationOnPage.x)*scaleFactor, (locationOnPage.y)*scaleFactor); This locationOnPage contains correct values (i.e., the annotation is placed where the mouse button was clicked) only if the zooming was 100%, and view boundaries exactly matched page boundaries (as shown on the picture: http://rghost.net/37251215/image.png). However, if the page is zoomed in/out, and does not exactly occupy the whole PDFView space (http://rghost.net/37251118/image.png) I do not get right coordinates: when I click in the bottom left corner of the PDFView, i see annotation appear in the bottom left corner of the page, which is not even on the page.. How could I do this right? All I need is the page origin position on the view, but there's no such a method, as it seems.. Thank you _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com