Annotation Flags

Every Annotation 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 several properties in the annotation record.

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:

  • An annotation with the noView flag won’t be rendered in the UI but may be printable.

  • An annotation with the noPrint flag won’t be printed.

  • An annotation with the noZoom flag won’t be magnified when zooming in. This is currently only enabled for StampAnnotation and TextAnnotation (with the exception of TextAnnotations with the callout property set).

  • An annotation with the noRotate flag won’t change its rotation when a page rotation is specified. Instead, it’ll be locked to the top-left corner of its bounding box. This is currently only enabled for NoteAnnotation.

  • An annotation with the readOnly flag set to true won’t respond to user inputs. It isn’t selectable, editable, or deletable.

  • An annotation with the locked flag set to true cannot be deleted or edited. However, this flag doesn’t restrict changes to the annotation’s contents, such as the text of a text annotation.

  • In contrast, an annotation with the lockedContents flag set to true can be edited or deleted, but its text content cannot be edited or deleted.

Setting Annotation Flags

Here’s an example of how to create a non-viewable annotation:

// Create a new annotation.
let annotation = ...

// Update the annotation flags.
annotation = annotation.set("noView", true);

// Add the newly created annotation to the document.
instance.create(annotation).then(...);
// Create a new annotation.
var annotation = ...

// Update the annotation flags.
annotation = annotation.set("noView", true);

// Add the newly created annotation to the document.
instance.create(annotation).then(...);