Some test text!

Search
Hamburger Icon

Web / Guides / Freeform rotation

Freeform rotation for PDF annotations

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).

freeform_rotation_polygon_annotation

Rotating annotations programmatically

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

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

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:

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

Using the 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:

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

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

Vice-versa, to enable rotation controls, you would use the 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 API.

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

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales