How do I Programmatically Add Annotations to the Saved Annotations list?

Q: How do I Programmatically Add Annotations to the Saved Annotations list?

Custom Saved Annotations

A: You need to create a PSPDFAnnotationSet and update the PSPDFSavedAnnotationsViewController’s sharedAnnotationStore annotationSets property, like so:

Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// The default shared annotations store.

// New annotations.
let annotations = ...
let sharedAnnotationStore = PSPDFSavedAnnotationsViewController.sharedAnnotationStore()

// Get the current annotation sets.
var annotationSets = sharedAnnotationStore.annotationSets;

// Append the annotations.
annotationSets.append(PSPDFAnnotationSet(annotations: annotations))

// Update the shared annotation store's annotation sets.
sharedAnnotationStore.annotationSets = annotationSets