How do I find out which PDF annotations are visible on screen (i.e. in PDFViewCtrl)?


Is it possible to obtain the on screen location of an annotation? I know we can call getAnnotationAt to get annotation at a specific location on the screen. Our objective is to locate which annotations are on the screen currently rendered and where they are located. Any ideas would be very helpful.


Yes it is possible to determine which annotations are visible and what their locations are. The basic procedure would be to determine which pages are on screen and then iterate through their annotations, determining one-by-one what each annotation’s screen coordinates are (and therefore if they are on screen). You can determine which pages are on screen by starting with the current page and then test if adjacent pages are on screen by using PDFViewCtrl’s selector ConvPagePtToScreenPt to see if the page’s corners are on the screen. Note that ConvPagePtToScreenPt will always return coordinates even if they are outside the viewable region, so you will need to check that they are not negative or greater than the height/width of the control.

Sample code showing how to iterate through all annotations in a page range can be found in the Annotation sample project, available on our website here: