This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/android/annotations/annotation-flags.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Define annotation behavior in a PDF with flags Android | Nutrient

Each Annotation supports AnnotationFlags that define its behavior and capabilities. Access these flags through the flags property. In Java, use getFlags() and setFlags().

Capabilities of flags

The PDF specification defines annotation flags. These flags control annotation behavior, onscreen and printed appearance, and available editing features. Use flags for tasks such as these:

  • Set HIDDEN to hide an annotation onscreen and exclude it from printing.
  • Set NOVIEW and PRINT to print an annotation without displaying it onscreen.
  • Set LOCKED and LOCKEDCONTENTS to prevent users from editing an annotation.

For the complete list of flags, refer to the AnnotationFlags API reference.

Usage example

The following example creates a locked annotation that users can’t edit:

// Create a new annotation.
val annotation: Annotation = FreeTextAnnotation(0, RectF(100f, 140f, 300f, 100f), "Locked text")
// Lock the annotation using flags.
annotation.flags = EnumSet.of(
AnnotationFlags.LOCKED,
AnnotationFlags.LOCKEDCONTENTS
)
// Add the newly created annotation to the document.
lifecycleScope.launch {
document.annotationProvider.addAnnotationToPage(annotation)
}