> 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/freeform-rotation.md).

# Freeform rotation for PDF annotations

Enhance PDF annotations with freeform rotation capabilities. Rotate Line, Polygon, Freehand, and more with a 360-degree control handle. Learn how to enable, disable, and configure rotation options pro

Line, Polygon, Polyline, Freehand, Ellipse, Rectangle, Stamp, FreeText annotations show a rotation control when selected. This control handle lets the user rotate the annotation with a full range (360 degrees).

![](https://3532544125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FX9YnTSKIHvV7m0A36LbO%2Fuploads%2Fgit-blob-c8c9f06771a4d6ded990796a3d38ceec7b29f42b%2Fcd85dba2d7a03daf81b3ae322656260d98c4b5da-1024x596.gif?alt=media)

## Rotating annotations programmatically

To rotate annotations programmatically, supported annotations have a `rotate` function that takes an angle to rotate by:

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const { annotationManager, Annotations } = instance.Core;
annotationManager.getAnnotationsList().forEach((annotation) => {
  if (annotation instanceof Annotations.RectangleAnnotation) {
    annotation.rotate(45);
  }
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Disabling freeform rotation

By default, freeform rotation is enabled for all Line, Polyline, Polygon or Freehand annotations. In order to disable it, the following can be done:

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

```js
const annotManager = instance.Core.annotationManager;
annotManager.setRotationOptions({
  isEnabled: false,
});
```

{% endcode %}

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

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

```js
const { annotManager } = instance;
annotManager.setFreeformRotationEnabled(false);
```

{% endcode %}
{% endtab %}
{% endtabs %}

Using the [setRotationOptions](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#setRotationOptions) API, then you can disable rotation completely. If you would like to disable free form rotation on certain annotations, then the following can be used instead:

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

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

    annotationManager.addEventListener('annotationChanged', (annotations, action) => {
      if (action === 'add') {
        annotations.forEach((annotation) => {
          annotation.disableRotationControl();
        });
      }
    });
  });
```

{% endcode %}

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

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

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

    annotManager.on('annotationChanged', (annotations, action) => {
      if (action === 'add') {
        annotations.forEach((annotation) => {
          annotation.setRotationControlEnabled(false);
        });
      }
    });
  });
```

{% endcode %}
{% endtab %}
{% endtabs %}

Vice-versa, to enable rotation controls, you would use the [enableRotationControl](https://sdk.apryse.com/api/web/Core.Annotations.Annotation.html#enableRotationControl) API.

## Configuring freeform rotation options

If you would like to configure the rotation type and rotation step sizes, that can be done with the same [setRotationOptions](https://sdk.apryse.com/api/web/Core.AnnotationManager.html#setRotationOptions) API.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const annotManager = instance.Core.annotationManager;
annotManager.setRotationOptions({
  isEnabled: true,
  defaultRotationType: Core.AnnotationManager.RotationTypes.SNAP_ROTATION,
  hotkeyTogglesRotationType: false,
  snapAngleStepSizeInDegrees: 60,
});
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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/freeform-rotation.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.
