public AnnotationsFromCodeViewController(NSData documentData)
            : base(new PSPDFDocument (documentData))
        {
            Document.Title = "Programmatically create annotations";

            var annotationsList = new List<PSPDFAnnotation> ();
            float maxHeight = Document.PageInfoForPage (0).RotatedPageRect.Size.Height;
            for (int i = 0; i < 5; i++) {
                var note = new PSPDFNoteAnnotation () {
                    BoundingBox = new RectangleF (new PointF (100, (50 + i * maxHeight / 5)), PSPDFNoteAnnotation.ViewFixedSize),
                    Contents = string.Format ("Note {0}", (5 - i)) // notes are added bottom-up
                };
                annotationsList.Add (note);
            }
            annotationsArr = annotationsList.ToArray ();
            Document.AddAnnotations (annotationsArr);
        }
 public PSPDFAnnotation[] AnnotationsForPage(uint page)
 {
     // it's important that this method is:
     // - fast
     // - thread safe
     // - and caches annotations (don't always create new objects!)
     lock (this) {
         if (annotations[(int)page] == null) {
             // create new note annotation and add it to the dict.
             var documentProvider = ProviderDelegate.ParentDocumentProvider ();
             var pageInfo = documentProvider.Document.PageInfoForPage (page);
             var noteAnnotation = new PSPDFNoteAnnotation () {
                 Page = page,
                 DocumentProvider = documentProvider,
                 Contents = string.Format ("Annotation from the custom annotationProvider for page {0}.", page + 1),
                 // place it top left (PDF coordinate space starts from bottom left)
                 BoundingBox = new RectangleF (100, pageInfo.RotatedPageRect.Size.Height - 100, 32, 32),
                 Editable = false
             };
             annotations [(int)page] = noteAnnotation;
         }
     }
     return new PSPDFAnnotation[] { annotations[(int)page] };
 }