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 an annotation’s behavior, its presentation onscreen 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
9
10
11
12
13
14
// Create a new annotation.
let annotation = PSPDFStampAnnotation(stampType: .confidential)

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

// Add the newly created annotation to the document.
document.add([annotation])

// To add an additional flag, use `update`.
annotation.flags.update(.hidden)

// To remove a flag, use `remove`.
annotation.flags.remove(.hidden)
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Create a new annotation.
PSPDFAnnotation *annotation = [[PSPDFStampAnnotation alloc] initWithStampType:PSPDFStampTypeConfidential];

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

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

// To add an additional flag, use bitwise OR with the flag value.
self.flags |= PSPDFAnnotationFlagHidden;

// To remove a flag, use bitwise AND with the reverse flag value.
self.flags &= ~PSPDFAnnotationFlagHidden;