Class: AnnotationManager

Core. AnnotationManager

Represents an object that manages the Annotations that appear on a Document's pages when displayed in a DocumentViewer.

new AnnotationManager(docViewer)

Creates a new instance of AnnotationManager.
Parameters:
Name Type Description
docViewer Core.DocumentViewer
Properties:
Name Type Description
controlPointSize number The size of annotation control points.
controlPointHitBoxScale number The scale of the hit box of the annotation control points. Increase to increase the selectable area.

Extends

Classes

Alignment

Members


<static> AnnotationChangedActions

The different action types for the annotationChanged event.
Properties:
Name Type Description
ADD string When the annotationChanged event triggered due to adding annotations
DELETE string When the annotationChanged event triggered due to deleting annotations
MODIFY string When the annotationChanged event triggered due to modifying annotations

<static, readonly> CenterAlignmentTypes

Enum representing center alignment types.
Properties:
Name Type Description
CENTER_HORIZONTAL string Aligns to the horizontal center.
CENTER_VERTICAL string Aligns to the vertical center.
CENTER string Aligns to the center.

<static, readonly> DistributeAlignmentTypes

Enum representing distribute alignment types.
Properties:
Name Type Description
DISTRIBUTE_HORIZONTAL string Distributes annotations horizontally.
DISTRIBUTE_VERTICAL string Distributes annotations vertically.

<static> Events

Properties:
Name Type Description
ANNOTATION_SELECTED string Core.AnnotationManager.annotationSelected
ANNOTATION_DESELECTED string Core.AnnotationManager.annotationDeselected
ANNOTATION_DOUBLE_CLICKED string Core.AnnotationManager.annotationDoubleClicked
ANNOTATION_CHANGED string Core.AnnotationManager.annotationChanged
ANNOTATION_NUMBERING_UPDATED string Core.AnnotationManager.annotationNumberingUpdated
UPDATE_ANNOTATION_PERMISSION string Core.AnnotationManager.updateAnnotationPermission
ANNOTATIONS_DRAWN string Core.AnnotationManager.annotationsDrawn
ANNOTATION_HIDDEN string Core.AnnotationManager.annotationHidden
SET_NOTE_TEXT string Core.AnnotationManager.setNoteText
ADD_REPLY string Core.AnnotationManager.addReply
DELETE_REPLY string Core.AnnotationManager.deleteReply
FIELD_CHANGED string Core.AnnotationManager.fieldChanged
FILE_ATTACHMENT_DATA_AVAILABLE string Core.AnnotationManager.fileAttachmentDataAvailable

<static> RotationTypes

Represents the types of rotations available to perform on an annotation.
Properties:
Name Type Description
SNAP_ROTATION string Rotate an annotation in discrete steps, such as 45 or 90 degrees
FREEFORM_ROTATION string Rotate an annotation continuously

<static, readonly> StandardAlignmentTypes

Enum representing standard alignment types.
Properties:
Name Type Description
LEFT string Aligns to the left.
TOP string Aligns to the top.
RIGHT string Aligns to the right.
BOTTOM string Aligns to the bottom.

<static> TabbingOrders

Represents the types of tabbing orders available to set on widgets in the document.
Properties:
Name Type Description
STRUCTURE string Order widgets according to the order found in the internal structure. This is default
ROW string Order widgets in terms of rows
COLUMN string Order widgets in terms of columns

Methods


addAnnotation(annotation [, options])

Adds the specified annotation to the managed list of annotations.
Parameters:
Name Type Argument Description
annotation Core.Annotations.Annotation | Array.<Core.Annotations.Annotation> An instance of Annotation.
options object <optional>
An object that can contain the following optional parameters.
Properties
Name Type Argument Default Description
imported boolean <optional>
false Whether the annotation was imported from another source or not
isUndoRedo boolean <optional>
false Whether the annotation change was caused by undo/redo or not
autoFocus boolean <optional>
false Whether the annotation's text input should be automatically focused if applicable. Relevant to FreeText and Callout annotations.
source string <optional>
What type of action cause this event (i.e. "redactionApplied")

addAnnotations(annotations [, options])

Adds the specified annotations to the managed list of annotations.
Parameters:
Name Type Argument Description
annotations Array.<Core.Annotations.Annotation> An array of annotations.
options object <optional>
An object that can contain the following optional parameters.
Properties
Name Type Argument Default Description
imported boolean <optional>
false Whether the annotations were imported from another source or not
isUndoRedo boolean <optional>
false Whether the annotation change was caused by undo/redo or not
autoFocus boolean <optional>
false Whether the annotation's text input should be automatically focused if applicable. Relevant to FreeText and Callout annotations.
source string <optional>
What type of action cause this event (i.e. "redactionApplied")

addEventListener(type, fn [, options])

Add a handler to the given event name
Parameters:
Name Type Argument Description
type string | number The name of the event to listen to
fn function The handler to be called when the event is triggered
options object <optional>
Optional options object for addEventListener
Properties
Name Type Description
once boolean If true then the handler will be called only once
Inherited From:
Returns:
Returns the object that 'addEventListener' is being called on
Type
object
Example
myObject.addEventListener('eventName', (eventParameter1, eventParameter2) => {
  ...
});

applyRedactions( [annotations])

Apply redaction annotations
Parameters:
Name Type Argument Description
annotations Core.Annotations.Annotation | Array.<Core.Annotations.Annotation> <optional>
An array of redaction annotations or a single redaction annotation. If nothing passed, apply all redactions. If the redaction annotations overlap with other annotations, it calls deleteAnnotations on the other annotations.
Returns:
Returns a promise that resolves with an array of redaction info when the redactions have been applied. If using WebViewer server, the promise will resolve with a URL to the redacted document.
Type
Promise.<(Array.<Core.AnnotationManager.RedactionInfo>|string)>

bringToBack(annotation)

Move the annotation to the beginning of the managed list of annotations, so that it will be shown behind all annotations.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that will be shown in the back.

bringToFront(annotation)

Move the annotation to the end of the managed list of annotations, so that it will be shown on top of all annotations.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that will be shown in the front.

canModify(annotation)

Whether or not the current user can modify the annotation.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation to check permissions on.
Returns:
Whether the annotation can be modified or not.
Type
boolean

canModifyContents(annotation)

Whether or not the current user can modify the annotation's contents.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation to check permissions on.
Returns:
Whether the annotation's contents can be modified or not.
Type
boolean

createAnnotationReply(annotation, initialText)

Creates an annotation that replies to the passed in annotation. Annotation replies are sticky note annotations.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation to add a reply to
initialText string The initialText for the annotation, defaults to the empty string
Returns:
The created annotation reply
Type
Core.Annotations.StickyAnnotation

deleteAnnotation(annotation [, options])

Deletes the specified annotation in the managed list of annotations. If an annotation is successfully deleted, the annotationChanged event will be fired with a "delete" action.
Parameters:
Name Type Argument Description
annotation Core.Annotations.Annotation | Array.<Core.Annotations.Annotation> An instance of Annotation.
options object <optional>
An object that can contain the following optional parameters.
Properties
Name Type Argument Description
imported boolean <optional>
Whether the annotation was imported from another source or not OR a option parameters contains
force boolean <optional>
If true then the annotation will be deleted regardless of the user's current permissions
isUndoRedo boolean <optional>
Whether the annotation change was caused by undo/redo or not
source string <optional>
What type of action cause this event (i.e. "redactionApplied")

deleteAnnotations(annotation [, options])

Deletes the specified annotations in the managed list of annotations. If an annotation is successfully deleted, the annotationChanged event will be fired with a "delete" action.
Parameters:
Name Type Argument Description
annotation Array.<Core.Annotations.Annotation> An array of annotations
options object <optional>
An object that can contain the following optional parameters.
Properties
Name Type Argument Description
imported boolean <optional>
Whether the annotations were imported from another source or not
force boolean <optional>
If true then the annotations will be deleted regardless of the user's current permissions
isUndoRedo boolean <optional>
Whether the annotation change was caused by undo/redo or not
source string <optional>
What type of action cause this event (i.e. "redactionApplied")

demoteUserFromAdmin()

Demote the current user so they are no longer an admin user.

deregisterAnnotationType(elementName, annotationClass)

Deregisters an annotation class.
Parameters:
Name Type Description
elementName string the string representing the xml element name of the annotation
annotationClass Class.<Core.Annotations.Annotation> the class (constructor) of the annotation
Returns:
true if deregistration was successful
Type
Boolean

deselectAllAnnotations()

Deselects all annotations. If an annotation is successfully deselected then the annotationSelected event will be triggered with two parameters: an array of annotations that were deselected and a "deselected" action. Note: the annotationSelected event has two parameters: an array of annotations and a string value of either "selected" or "deselected" The annotationDeselected event will also be triggered with one parameter: an array of annotations that were deselected.

deselectAnnotation(annotation)

Deselects the specified annotation. If an annotation is successfully deselected then the annotationSelected event will be fired with a "deselected" action. Note: the annotationSelected event has two parameters: an array of annotations and a string value of either "selected" or "deselected"
Parameters:
Name Type Description
annotation Core.Annotations.Annotation An instance of Annotation.

deselectAnnotations(annotations)

Deselects the specified annotations. If annotations are successfully deselected then the annotationSelected event will be fired with a "deselected" action. Note: the annotationSelected event has two parameters: an array of annotations and a string value of either "selected" or "deselected"
Parameters:
Name Type Description
annotations Array.<Core.Annotations.Annotation> An array of annotation instances

disableAnnotationNumbering()

Disables annotation numbering.

disableDraggingAcrossPages()

Disable dragging annotations across pages.

disableFreeTextEditing()

Disables the editing of free text annotations directly on the annotation.

disableReadOnlyMode()

Disables read-only mode in the viewer.

disableRedaction()

Disable redaction tools

disableStampVectorAppearance()

Disables the use of vector appearances for stamp annotations and always uses a fixed size bitmap. This may be much faster in certain situations but will appear blurry at higher zoom levels.

disableWidgetTabOrdering()

[PDF Document only] Disables document tab ordering APIs and automatically reading the widget tab order from the document on document loaded.

drawAnnotations(options)

Draws all annotations associated with the given page number. Note that the entire annotation canvas for the page will be redrawn.
Parameters:
Name Type Description
options object An object that can contain the following parameters
Properties
Name Type Argument Description
pageNumber number The page number of the page to draw
overrideCanvas object <optional>
Optionally draw directly to this canvas
majorRedraw boolean <optional>
Signify that this is a major redraw, so widget-like annotations must be re-rendered as well
overrideContainer object <optional>
Optionally the container HTML element that the widget annotations should be appended to
Returns:
Returns a promise that resolves when all the annotations on the page have been drawn
Type
Promise.<any>

drawAnnotationsFromList(annotationList)

Draws all the pages associated with the annotations in the list as long the page is visible. A single annotation can also be passed in.
Parameters:
Name Type Description
annotationList Array.<Core.Annotations.Annotation> | Core.Annotations.Annotation List of annotations or a single annotation object
Returns:
Returns a promise that resolves when all the annotations in the annotationList have been drawn
Type
Promise.<any>

enableAnnotationNumbering()

Enables annotation numbering. As annotations are imported/created they will each be numbered. Starting at 1, each annotation will be assigned the next greatest available number. Only listable will be numbered and contribute to the count.

enableDraggingAcrossPages()

Enable dragging annotations across pages.

enableReadOnlyMode()

Enables read-only mode in the viewer. In this mode no annotations can be added or commented on.

enableRedaction()

Enable redaction tools Please use enableRedaction or disableRedaction without passing parameters Using a parameter is deprecated in version 8.0

enableWidgetTabOrdering()

[PDF Document only] Enables document tab ordering APIs and automatically reading the widget tab order from the document on document loaded.

exportAnnotationCommand()

Gets an XML string from the last time this function was called. XML string specifies the added, modified and deleted annotations. Added and modified annotations will have their XFDF representation included while deleted annotations will only include their id.
Returns:
Returns a promise that resolves to an XFDF command string
Type
Promise.<string>

exportAnnotations( [options])

Exports all annotations as an XFDF (XML) string
Parameters:
Name Type Argument Description
options object <optional>
Options for the export. Set options.widgets or options.links or options.fields to false to disable exporting of them.
Properties
Name Type Argument Description
annotList Array.<Core.Annotations.Annotation> <optional>
An array of annotations to only export the XFDF for those particular annotations.
annotationList Array.<Core.Annotations.Annotation> <optional>
An array of annotations to only export the XFDF for those particular annotations.
widgets boolean <optional>
Whether to export widget information
links boolean <optional>
Whether to export links information
fields boolean <optional>
Whether to export fields information
useDisplayAuthor boolean <optional>
Whether to export annotations with the Display Author name from annotationManager.getDisplayAuthor()
generateInlineAppearances boolean <optional>
Whether to generate custom appearance strings for annotations that have an appearance generated on export (e.g. freetext). Default: true
Returns:
Returns a promise that resolves with the XFDF (XML) annotations as a string
Type
Promise.<string>

getAnnotationById(id [, annotationList])

Gets an annotation object by the annotation's ID.
Parameters:
Name Type Argument Description
id string The ID of the annotation.
annotationList Array <optional>
Optionally pass your own array of annotations to search in
Returns:
An annotation object.
Type
Core.Annotations.Annotation

getAnnotationByMouseEvent(event [, includeWidgetsAndLinks])

Gets the top-most annotation using a DOM mouse event. This method can be used to test if a mouse point will hit any annotations on pages.
Parameters:
Name Type Argument Default Description
event MouseEvent A DOM mouse event.
includeWidgetsAndLinks boolean <optional>
false Indicates whether to include widget and link annotations under the mouse event.
Returns:
An annotation object.
Type
Core.Annotations.Annotation

getAnnotationCopy(annotation, options)

Returns a deep copy of the annotation
Parameters:
Name Type Description
annotation Core.Annotations.Annotation An instance of Annotation to be copied.
options Object Options for this function
Properties
Name Type Argument Description
copyAssociatedLink boolean <optional>
Whether to make a deep copy of an associated link
copyReplies boolean <optional>
Whether to make a deep copy of replies associated with the annotation
copyWithSameId boolean <optional>
Whether to copy the annotation with the same Id
Returns:
a copy of the annotation, null if annotation cannot be copied
Type
Core.Annotations.Annotation

getAnnotationFromPopup(popup)

Gets the annotation associated with the popup object.
Parameters:
Name Type Description
popup object The popup object associated with an annotation
Returns:
The annotation that the popup belongs to
Type
Core.Annotations.Annotation

getAnnotationsByMouseEvent(event [, includeWidgetsAndLinks])

Gets the annotations underneath the cursor using a DOM mouse event. This method can be used to test if a mouse point will hit annotations on pages.
Parameters:
Name Type Argument Default Description
event MouseEvent A DOM mouse event.
includeWidgetsAndLinks boolean <optional>
false Indicates whether to include widget and link annotations under the mouse event.
Returns:
An array of annotation objects.
Type
Array.<Core.Annotations.Annotation>

getAnnotationsList()

Gets the list of all annotations managed by the AnnotationManager.
Returns:
An array of Annotations.
Type
Array.<Core.Annotations.Annotation>

getCopiedAnnotations()

Get copied annotations.
Returns:
returns array of copied annotations
Type
Array.<Core.Annotations.Annotation>

getCurrentUser()

Returns the user name of the current user.
Returns:
The user name of the current user.
Type
string

getDisplayAuthor(annotationUserId)

Annotations may set the author to a unique id which isn't suitable for display in the UI. this function gets the author name of the annotation that should be displayed.
Parameters:
Name Type Description
annotationUserId string Annotation userId
Returns:
The display author name
Type
string

getEditBoxManager()

Returns:
Returns an instance of EditorBoxManager
Type
Core.EditBoxManager

getFieldManager()

Gets the associated field manager.
Returns:
Type
Core.Annotations.Forms.FieldManager

getFormFieldCreationManager()

Gets the associated form field creation manager
Returns:
Returns an instance of FormFieldCreationManager
Type
Core.FormFieldCreationManager

getGroupAnnotations(annotation)

Gets all the annotations that are grouped with the passed in annotation, including said annotation.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation An annotation in the group
Returns:
Gets all the annotations that are grouped with the passed in annotation, including said annotation.
Type
Array.<Core.Annotations.Annotation>

getNumberOfGroups()

Gets the number of annotations in the current selection
Returns:
The number of groups in the current selection. A loose annotation is a group of 1.
Type
number

getRegisteredAnnotationTypes()

Gets a map of registered annotations. This can be modified directly, instead of using AnnotationManager#registerAnnotationType and AnnotationManager#deregisterAnnotationType.
Returns:
a JavaScript object containing a key-value map, where the key is the annotation element name and the value is an array of Annotation classes.
Type
object

getRootAnnotation(annotation)

Gets the root annotation that this annotation is replying to. If this annotation is not replying to anything then the root is itself.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation from which to find the root annotation in the reply chain
Returns:
The root annotation
Type
Core.Annotations.Annotation

getRotationOptions()

Gets the rotation options for annotation manager.
Returns:
An object containing rotation options for annotation manager.
Type
object
Example
const { Core } = instance;
const annotManager = Core.documentViewer.getAnnotationManager();
const rotationOptions = annotManager.getRotationOptions();

getSelectedAnnotations()

Returns the list of selected annotations.
Returns:
An array of selected annotations.
Type
Array.<Core.Annotations.Annotation>

getSemanticDiffAnnotations()

Returns a list of annotations that were added by DocumentViewer.startSemanticDiff returns an empty list if semanticDiff was not started

getSnapDefaultOptions()

Get the current snap options for annotation tool snapping
Returns:
The snap mode options.
Type
Core.AnnotationManager.snapDefaultOptions

getTabOrder()

[PDF Document only] Gets the tab order in the document.
Returns:
The tab order.
Type
string

groupAnnotations(primaryAnnotation, annotations)

Groups an array of annotations
Parameters:
Name Type Description
primaryAnnotation Core.Annotations.Annotation The primary annotation for this group.
annotations Array.<Core.Annotations.Annotation> The array of annotations to group.

hasAnnotation(annotation)

Determines if the specified annotation exists in the managed list of annotations.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation An instance of Annotation.

hideAnnotation(annot)

Hides the specified annotation.
Parameters:
Name Type Description
annot Core.Annotations.Annotation The annotation to hide

hideAnnotations(annots)

Hides all of the annotations in the list
Parameters:
Name Type Description
annots Array.<Core.Annotations.Annotation> Array of annotations to hide

hideDetachedReplies()

Hide and unlist detached replies (replies with a missing parent). This can only be called before a document is loaded.

importAnnotationCommand(xfdfString)

Updates the viewer with the xfdf changes (add/modify/delete) in the xml string
Parameters:
Name Type Description
xfdfString string The XML annotation updates as a string
Returns:
A promise that resolves to the list of annotations that were updated
Type
Promise.<Array.<Core.Annotations.Annotation>>

importAnnotations(xfdfString [, options])

Loads XFDF annotations into the viewer
Parameters:
Name Type Argument Description
xfdfString string The XFDF annotations as a string
options object <optional>
The options for importing
Properties
Name Type Argument Description
batchSize number <optional>
The number of annotations to import in each batch (default 100)
batchDelay number <optional>
The amount of time in milliseconds to delay between importing each batch (default 0)
replace Core.Annotations.Annotation | Array.<Core.Annotations.Annotation> <optional>
The type of existing annotations that will be removed before import starts (default [])
Returns:
Returns a promise that resolves with the annotations have been imported
Type
Promise.<any>

isAnnotationRedactable(annotation)

Check if an annotation is redactable (is a redaction annotation the user can apply). When using Webviewer Server, single redaction aren't allowed, only redact all is allowed
Parameters:
Name Type Description
annotation Core.Annotations.Annotation An annotation to check if it redactable
Returns:
True if annotation can be redacted (WebViewer is set up correctly for applying), false otherwise
Type
boolean

isAnnotationSelected(annotation)

Returns whether an annotation is currently selected
Parameters:
Name Type Description
annotation Core.Annotations.Annotation An instance of Annotation.
Returns:
true if annotation is selected, false otherwise
Type
boolean

isApplyRedactionEnabled()

Check if applying redaction is enabled
Returns:
True if applying redactions is enabled, false otherwise
Type
boolean

isCreateRedactionEnabled()

Check if creating redaction is enabled
Returns:
True if creating redactions is enabled, false otherwise
Type
boolean

isDraggingAcrossPagesEnabled()

Check if dragging annotations across pages is enabled.
Returns:
True if dragging annotations across pages is enabled, false otherwise.
Type
boolean

isFreeTextEditingEnabled()

Returns whether free text editing is enabled directly on the annotation.
Returns:
true if free text editing is enabled, false otherwise.
Type
boolean

isReadOnlyModeEnabled()

Returns whether the viewer is currently in read-only mode.
Returns:
true if the current viewer is in read-only mode, false otherwise.
Type
boolean

isUserAdmin()

Returns whether the current user has admin privileges.
Returns:
true if the current user is an admin, false otherwise.
Type
boolean

jumpToAnnotation(annotation [, options])

Jumps to the page of the annotation and if it isn't visible then centers it in the window.
Parameters:
Name Type Argument Description
annotation Core.Annotations.Annotation The annotation to be jumped to.
options Object <optional>
Optional settings for jump behaiour. Default will guarantee the annotation will be on the screen at the current zoom level.
Properties
Name Type Argument Default Description
horizontalOffset string <optional>
auto Percentage of the screen the annotation will jump to, '0%' being the left of the page. Anything over '100%' and under '0%' will be off the page.
verticalOffset string <optional>
auto Percentage of the screen the annotation will jump to, '0%' being the top of the page. Anything over '100%' and under '0%' will be off the page.
zoom string <optional>
1 The level of zoom, 1 being 100% zoom.
fitToView boolean <optional>
false If set to true the zoom will fit the entire annotation within the viewport.
isSmoothScroll boolean <optional>
false If set to true, the viewer will scroll to the annotation in a smooth way.

pasteCopiedAnnotations( [useMouseLocation])

Pastes the currently copied annotations.
Parameters:
Name Type Argument Default Description
useMouseLocation boolean <optional>
false Whether or not to paste the annotations based on the position of the mouse cursor in the window, accounting for the scroll position

promoteUserToAdmin()

Promote the current user to be an admin user. Admin users can edit any annotations.

redrawAnnotation(annotation)

Redraws the specified annotation. Note that the entire annotation canvas for the page will be redrawn.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation to be redrawn.

registerAnnotationType(elementName, annotationClass)

Registers an annotation class. Annotations that are registered will be serialized and deserialized by the AnnotationManager.
Parameters:
Name Type Description
elementName string the string representing the xml element name of the annotation
annotationClass Class.<Core.Annotations.Annotation> the class (constructor) of the annotation
Returns:
true if registration was successful
Type
Boolean

removeEventListener( [type] [, fn])

Remove a handler of the given event name and namespace (if given) or with a function reference
Parameters:
Name Type Argument Description
type string | number <optional>
The name of the event to remove the handler of with an optional namespace.
fn function <optional>
The handler associated with this event to be removed. If fn is undefined, all the handlers of the given event namespace will be removed. If you are not passing in this parameter then a namespace must be used with the event name.
Inherited From:
Returns:
Returns the object that 'removeEventListener' is being called on
Type
object
Example
myObject.removeEventListener('eventName.namespace');
myObject.removeEventListener('eventName', fn);

selectAnnotation(annotation)

Selects the specified annotation. If an annotation is successfully selected then the annotationSelected event will be fired with a "selected" action. Note: the annotationSelected event has two parameters: an array of annotations and a string value of either "selected" or "deselected"
Parameters:
Name Type Description
annotation Core.Annotations.Annotation An instance of Annotation.

selectAnnotations(annotations)

Selects the specified annotations. If an annotation is successfully selected then the annotationSelected event will be fired with a "selected" action. Note: the annotationSelected event has two parameters: an array of annotations and a string value of either "selected" or "deselected"
Parameters:
Name Type Description
annotations Array.<Core.Annotations.Annotation> An array of Annotations.

setAnnotationCanvasTransform(annotCanvasContext, zoom, rotation)

Set the page transform of an annotation canvas
Parameters:
Name Type Description
annotCanvasContext CanvasRenderingContext2D Annotation canvas context to draw on
zoom number The zoom or the scaling of the page canvas
rotation Core.PageRotation The rotation of the page canvas

setAnnotationDisplayAuthorMap(mapFunction)

Sets the mapping function used to get the display name for annotation authors and is used when calling getDisplayAuthor.
Parameters:
Name Type Description
mapFunction function The mapping function to use. The function is passed a userID/GUID and should return the display name for the UI.
Example
annotManager.setAnnotationDisplayAuthorMap((annotationUserId) => {
  if (annotationUserId === '1') {
    return 'John';
  } else {
    return 'Guest';
  }
});

setAnnotationRichTextStyle(annotation, style)

Sets the rich text style for the specified annotation
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that will have its rich text style updated.
style Core.Annotations.Annotation.RichTextStyle The object to update the rich text style to.

setAnnotationStyles(annotation, newStyles)

Set the styles for the annotation
Parameters:
Name Type Description
annotation Core.Annotations.Annotation an annotation of which the styles will be changed.
newStyles object | function if an object is used, it should contain properties of the new styles. If a function is used, the current styles will be passed as its argument and the function should return an object which contains properties of the new styles. Example of valid properties: StrokeColor, TextColor, FillColor, FontSize, Opacity, StrokeThickness, Precision, Scale, OverlayText, Style and Dashes.

setBeforeSubmitFormActionCallback(callback)

Sets the function to be called before a submit form action is triggered. IMPORTANT: If either no value or a falsy value is returned from the callback, then the submitForm API will be cancelled. Please ensure your callback function returns the boolean true in order for the submit form action to complete
Parameters:
Name Type Description
callback Core.AnnotationManager.setBeforeSubmitFormActionCallbackFunction The function that will be called prior to invocation of the SubmitForm API.

setCurrentUser(user)

Sets the current user of the viewer.
Parameters:
Name Type Description
user string the user name of the current user.

setCustomAppearanceHandler(func)

Used to load appearance documents for annotations with custom appearances. The function will be called when an annotation is imported that contains a custom appearance that references a filename.
Parameters:
Name Type Description
func function Function which must return Document object created with Core.createDocument

setNoteContents(annotation, text)

Sets the value of the note for the specified annotation.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that will have its note updated.
text string The value to update the note text to.

setOldStickyNoteRenderingDate(date)

Changes the sticky note rendering to the old implementation when the sticky note has been created before the specified date.
Parameters:
Name Type Description
date number The date timestamp to use

setPermissionCheckCallback(callback)

Sets the function that should be used to determine if the annotation can be modified or not.
Parameters:
Name Type Description
callback function The function that should be called. Should return true or false.

setRedrawThrottleRate(value)

Sets the rate at which the redrawing of annotations is throttled. This can improve annotation rendering on lower quality devices and browsers.
Parameters:
Name Type Description
value number The throttled rate at which annotations will be redrawn, in milliseconds

setRotationOptions(options)

Sets the rotation options for annotation manager.
Parameters:
Name Type Description
options object An object that can contain the following parameters
Properties
Name Type Argument Description
isEnabled boolean <optional>
Whether rotations are enabled or not.
hotkeyTogglesRotationType boolean <optional>
Determines if rotation type performed is toggled when holding down shift key.
defaultRotationType string <optional>
Determines which rotation type will be performed without holding shift key.
snapAngleStepSizeInDegrees number <optional>
The angle (in degrees) applied to each snap rotation. Valid range is between 0 and 180.
Example
// Enables snap rotations at 60 degree steps, without having to hold shift key.
// Hotkey will not toggle rotation type (ie, freeform rotations are disabled).
const { Core } = instance;
const annotManager = Core.documentViewer.getAnnotationManager();
annotManager.setRotationOptions({
  isEnabled: true,
  defaultRotationType: Core.AnnotationManager.RotationTypes.SNAP_ROTATION,
  hotkeyTogglesRotationType: false,
  snapAngleStepSizeInDegrees: 60
});

setSnapDefaultOptions(options)

Set the snap options for annotation tool snapping
Parameters:
Name Type Description
options Core.AnnotationManager.snapDefaultOptions The snap mode options.

setSubmitFormActionCallback(callback)

Sets the function to be called when a submit form action is triggered.
Parameters:
Name Type Description
callback function The function that should be called. Will be passed the form data.

setTabOrder(tabOrder)

[PDF Document only] Sets the desired tab order of widgets in the document. This requires the full API.
Parameters:
Name Type Description
tabOrder string The desired tab order
Returns:
A promise that resolves when complete.
Type
Promise.<void>
Example
annotManager.setTabOrder(instance.Core.AnnotationManager.TabbingOrders.ROW);

showAnnotation(annot)

Shows the annotation
Parameters:
Name Type Description
annot Core.Annotations.Annotation The annotation to show

showAnnotations(annots)

Shows all of the annotations in the list
Parameters:
Name Type Description
annots Array.<Core.Annotations.Annotation> Array of annotations to show

showDetachedReplies()

Render and list detached replies (replies with a missing parent). This can only be called before a document is loaded.

trigger(type [, data])

Calls the handlers of the event name with given data
Parameters:
Name Type Argument Description
type string | number event name of which the handlers will be called.
data * <optional>
data that will be passed to the handlers. If data is an array, it will be spread and then passed to the handlers
Inherited From:
Returns:
Returns the object that 'trigger' is being called on
Type
object
Example
myObject.trigger('eventName');
myObject.trigger('eventName', [eventParameter1, eventParameter2]);

ungroupAnnotations(annotations)

Ungroups an array of annotations
Parameters:
Name Type Description
annotations Array.<Core.Annotations.Annotation> The array of annotations to ungroup.

updateAnnotation(annotation)

Redraws the annotations on the same page as the specified annotation if the annotation has been added.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation An instance of Annotation.

updateAnnotationRichTextStyle(annotation, style [, start] [, end])

Update the rich text style for the specified annotation
Parameters:
Name Type Argument Description
annotation Core.Annotations.Annotation The annotation that will have its rich text style updated.
style Core.Annotations.Annotation.StyleObject The object to update the rich text style to.
Properties
Name Type Description
'underline' boolean boolean value for whether string should be underlined
'line-through' boolean boolean value for whether string should be strike through
'font-weight' string String for the font weight of the rich text (can be 'bold')
'font-style' string String for font style of the rich text (can be 'italic')
'color' string string for what color to set text to
start number <optional>
Optional starting index to apply the style, if not set, will start at 0
end number <optional>
Optional ending index for the style, if not set, will apply style to end of text

updateAnnotationState(annotation, state, stateModel, message)

Updates the annotation state. This is done by creating an annotation that replies to the passed in annotation.
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation to add a reply to
state string Annotations may have an author-specific state associated with them. Valid states are for Review stateModel: Accepted, Rejected, Cancelled, Completed, None. Default is None. Valid states are for Marked stateModel: Marked and Unmarked. Default is Unmarked.
stateModel string Gets or sets the stateModel of the annotation. stateModel has two statemodels: Marked, Review. Default is Review.
message string Message to be set when the state is updated.
Returns:
The created annotation reply
Type
Core.Annotations.StickyAnnotation

updateCopiedAnnotations()

Copies the currently selected annotations.

Type Definitions


AnnotationChangedInfoObject

Type:
  • Object
Properties:
Name Type Description
imported boolean A boolean that will be true if the annotation change is the result of importing annotations using importAnnotations, importAnnotationCommand or if the imported parameter is set to true when calling addAnnotations or deleteAnnotations
isUndoRedo boolean A boolean that will be true if the annotation change is the result of an undo or redo action
source string An optional string that indicates what type of action caused this event (i.e. "redactionApplied") Core.AnnotationManager.AnnotationChangedSources

AnnotationChangedSources

Sources for what triggered the annotationChanged event
Type:
  • string
Properties:
Name Type Description
MOVE string Source for when the annotation was moved
RESIZE string Source for when the annotation was resized
ROTATE string Source for when the annotation was rotated
TEXT_CHANGED string Source for when the annotation's text was changed (FreeText)
NOTE_CHANGED string Source for when the annotation's note was changed
DRAGGING_ACROSS_PAGES string Source for when the annotation was dragged across pages

RedactionInfo

Type:
  • object
Properties:
Name Type Description
pageNumber number The page number of the redaction
rect Core.Math.Rect A rect containing the bounding box of the redaction

setBeforeSubmitFormActionCallbackFunction(submitFormParams)

Parameters:
Name Type Description
submitFormParams Core.AnnotationManager.SubmitFormParams An object corresponding to the parameters passed when the submitForm API was invoked

snapDefaultOptions

Type:
  • Object
Properties:
Name Type Description
radiusThreshold number The distance threshold in pixel for snap feature to be effective.
indicatorSize number The side length in pixels of the snap indicator's bounding square.
indicatorColor string The color of the snap indicator. Accepts CSS HEX or CSS RGBA value.

SubmitFormParams

Type:
  • Object
Properties:
Name Type Description
fields array An array of field names to submit
empty boolean If true, submit all fields, including those that have no value. If false, exclude fields that currently have no value
fdf boolean If true, form data is submitted as FDF. If false, it is submitted as XFDF
url string The URL to submit the form data to

Events


addReply

Triggered when a reply has been added to an annotation
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that was added
parent Core.Annotations.Annotation The annotation that is the direct parent of the first annotation
root Core.Annotations.Annotation The annotation that is the root parent of the first annotation (may be the same as parent)

annotationChanged

Triggered when an annotation or annotations have been changed (added, deleted, modified). Attach like annotManager.addEventListener('annotationChanged', callback)
Parameters:
Name Type Description
annotations Array.<Core.Annotations.Annotation> The annotations that were changed
action string The action that occurred (add, delete, modify)
info Core.AnnotationManager.AnnotationChangedInfoObject An object containing extra information about the annotationChanged event

annotationDeselected

Triggered after annotations have been deselected.
Parameters:
Name Type Description
annotationList Array.<Core.Annotations.Annotation> List of annotations that have been deselected.

annotationDoubleClicked

Triggered after an annotation has been double clicked
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that has been double clicked

annotationHidden

Triggered after annotations have been hidden/shown.
Parameters:
Name Type Description
annotationList Array.<Core.Annotations.Annotation> List of annotations that were hidden or shown
hidden boolean Whether the annotations have been hidden or shown

annotationsDrawn

Triggered after annotations have been drawn for a page
Parameters:
Name Type Description
pageNumber object The page number of all the annotations that were just drawn

annotationSelected

Triggered after annotation selection has been changed.
Parameters:
Name Type Description
annotationList Array.<Core.Annotations.Annotation> List of annotations that have selected or deselected.
action string Either 'selected' or 'deselected'

deleteReply

Triggered when a reply has been deleted from an annotation
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that was deleted
root Core.Annotations.Annotation The annotation that is the root parent of the first annotation

fieldChanged

Triggered when a field's value has been changed. Attach like annotManager.addEventListener('fieldChanged', callback)
Parameters:
Name Type Description
field object The field that was changed
value string The field's new value

fileAttachmentDataAvailable

Triggered after the file attachment data is available after double clicking on the annotation
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that was double clicked
fileInfo object Information of the file attachment
Properties
Name Type Description
fileData Blob The blob data of the file attachment
filename string The name of the file attachment
mimeType string The mimetype attribute of the file attachment

setNoteText

Triggered when the text should be set on a note
Parameters:
Name Type Description
annotation Core.Annotations.Annotation The annotation that needs to have its note text updated
root Core.Annotations.Annotation The annotation that is the root parent of the first annotation

updateAnnotationPermission

Triggered when permissions for annotations should be updated. This might be when the user changes or readonly is switched to. If no annotation is specified then every annotation should be updated.
Parameters:
Name Type Argument Description
annotation Core.Annotations.Annotation <optional>
The annotation that needs to have its permissions updated