Prevent Editing the Content of a Text Annotation

Q: How can I allow users to move, resize, change properties, etc. of text annotations but ensure they don’t change their content?

A: PSPDFKit for Web supports different annotation flags. One of these flags is lockedContent. When this flag is set to true, an annotation can be moved or resized, and its properties can be changed or the annotation can be deleted, but its text content cannot be edited or deleted:

PSPDFKit.load({
  ...configuration
}).then((instance) => {
  // Get the first annotation from a document.
  const annotation = instance.getAnnotation(0).first();

  // Update the annotation flags.
  const a = annotation.set("lockedContent", true);

  instance.update(a);
});

This has been tested with PSPDFKit for Web 2023.4.6.