> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/annotation/annotationmanager/permissions.md).

# Set User Annotation Permissions in WebViewer JavaScript PDF Viewer

Control user annotation permissions using web viewer with ease. Define who can modify annotations and customize settings. Learn about default behaviors, editable vs. non-editable annotations, admin us

WebViewer supports client side user permissions for annotations to control which users can modify which annotations. By default users can only modify annotations that they have created but there are a number of ways that this can be customized if you wish.

## Default behavior

When WebViewer is instantiated it sets the current user name to `Guest`. You can set the initial user using the `annotationUser` option in the WebViewer constructor. After WebViewer has been instantiated you can also programmatically set the current user name using the [`setCurrentUser`](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#setCurrentUser__anchor) function on the AnnotationManager.

When the user creates a new annotation, the [annotation's Author property](https://sdk.apryse.com/api/web/Core.Annotations.Annotation.html#Author__anchor) will be set to the current user name. The user will be able to modify or delete any annotations that have an Author value equal to their user name and these annotations will have a blue border when selected. The user will also be able to update the text on the note associated with the annotation.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-f07a61045c77833eb1182f9ec231d094900a0377%2Fa5a767fea9b4b931e8a87746a01e59ad7454cced-160x130.png?alt=media)

Any annotations that have a different Author value will be displayed with a red border when selected and the user will not be able to modify or delete them. They will also not be able to modify the note text but they will be able to add replies.

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-5802c79e4adcf496d04758c40ce09dc8f33040ed%2F4704bd9afd857954822e3039ff6413a3608b9ead-160x130.png?alt=media)

## Admin users

WebViewer has an `isAdminUser` boolean option that can be passed to the WebViewer constructor. When set to true the user is considered to be an administrator and is able to modify and delete any annotation or message regardless of the user that created it. You can programmatically toggle this property for the current user by calling [`promoteUserToAdmin`](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#promoteUserToAdmin__anchor).

## Readonly mode

There is also an `enableReadOnlyMode` boolean option that puts WebViewer into readonly mode. When in readonly mode annotations cannot be created, modified or deleted and no replies can be added to any annotation messages. You can programmatically toggle this mode by calling [`enableReadOnlyMode`](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#enableReadOnlyMode).

## Annotation properties

There are [several properties](https://sdk.apryse.com/api/web/Core.Annotations.Annotation.html#Annotation__anchor) that individual annotations can have that affect whether an annotation can be edited or not.

* **ReadOnly**: Neither the annotation nor the annotation's note can be deleted or modified.
* **Locked**: The annotation cannot be deleted or modified but the annotation's note can be changed.
* **LockedContents**: The annotation can be deleted or modified but the annotation's note cannot be changed.

## Custom permissions

You can define your own logic for whether an annotation can be modified or not using the [setPermissionCheckCallback function on AnnotationManager](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#setPermissionCheckCallback__anchor).

This function takes a callback function that you define that should return true if the current user should have permission to modify the annotation and false otherwise. For example:

{% tabs %}
{% tab title="JavaScript (SDK v8.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    const { annotationManager } = instance.Core;

    annotationManager.setPermissionCheckCallback((author, annotation) => {
      const currentUserIsAuthor = annotation.Author === annotManager.getCurrentUser();

      // any annotation with 50% opacity will also be editable regardless of the author
      const customPermission = annotation.Opacity === 0.5;

      return currentUserIsAuthor || customPermission;
    });
  });
```

{% endcode %}

[AnnotationManager.setPermissionCheckCallback](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#setPermissionCheckCallback)
{% endtab %}

{% tab title="JavaScript (SDK v6.0+)" %}
{% code lineNumbers="true" %}

```js
WebViewer(...)
  .then(instance => {
    const { annotManager } = instance;

    annotManager.setPermissionCheckCallback((author, annotation) => {
      const currentUserIsAuthor = annotation.Author === annotManager.getCurrentUser();

      // any annotation with 50% opacity will also be editable regardless of the author
      const customPermission = annotation.Opacity === 0.5;

      return currentUserIsAuthor || customPermission;
    });
  });
```

{% endcode %}

[AnnotationManager.setPermissionCheckCallback](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#setPermissionCheckCallback)
{% endtab %}
{% endtabs %}

## Next steps

Learn how to [change](/web/annotation/annotationmanager/display-authors.md) how users are displayed for clarity and customization.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/web/annotation/annotationmanager/permissions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
