Annotation Flags

Every PSPDFAnnotation in a document can specify flags that further define its behavior and capabilities. With PSPDFKit, you can access these flags directly on your annotation objects using the flags property.

Capabilities of Flags

Annotation flags are part of the PDF specification and define the annotation's behavior, its presentation on screen and on paper, and the available editing features given to your users. Here are a few examples of things you can do with flags:

💡 Tip: Check out the PSPDFAnnotationFlags API reference for a complete list of available flags.

Usage Example

Here's an example of how to create a locked annotation, i.e. an annotation that can't be modified by your users:

Copy
1
2
3
4
5
6
7
8
// Create a new annotation
let annotation = ...

// Update the annotation flags
annotation.flags.update(with: [.locked, .lockedContents])

// Add the newly created annotation to the document
document.add([annotation])
Copy
1
2
3
4
5
6
7
8
// Create a new annotation
PSPDFAnnotation *annotation = ...

// Update the annotation flags
annotation.flags |= ~PSPDFAnnotationFlagLocked | PSPDFAnnotationFlagLockedContents;

// Add the newly created annotation to the document
[document addAnnotations:@[annotation] options:nil];