-
addAnnotation(annotation [, options])
-
Adds the specified annotation to the managed list of annotations.
Parameters:
Name |
Type |
Argument |
Description |
annotation |
Annotations.Annotation
|
Array.<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. |
|
-
addAnnotations(annotations [, options])
-
Adds the specified annotations to the managed list of annotations.
Parameters:
Name |
Type |
Argument |
Description |
annotations |
Array.<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. |
|
-
applyRedactions( [annotations])
-
Apply redaction annotations
Parameters:
Name |
Type |
Argument |
Description |
annotations |
Annotations.Annotation
|
Array.<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.<CoreControls.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:
-
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:
-
canModify(annotation)
-
Whether or not the current user can modify the annotation.
Parameters:
Name |
Type |
Description |
annotation |
object
|
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 |
object
|
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 |
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
-
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 |
Annotations.Annotation
|
Array.<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 |
boolean
|
<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.<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 |
boolean
|
<optional>
|
What type of action cause this event (i.e. "redactionApplied") |
|
-
deregisterAnnotationType(elementName, annotationClass)
-
Deregisters an annotation class.
Parameters:
Name |
Type |
Description |
elementName |
string
|
the string representing the xml element name of the annotation |
annotationClass |
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 trigger with a "deselected" action and a null value as the array of annotations parameter.
Note: the annotationSelected event has two parameters: an array of annotations and a string value of either "selected" or "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:
-
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:
-
disableFreeTextEditing()
-
Disables the editing of free text annotations directly on the annotation.
-
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.
-
drawAnnotations(pageNumber [, overrideCanvas] [, majorRedraw] [, overrideContainer])
-
Draws all annotations associated with the given page number.
Note that the entire annotation canvas for the page will be redrawn.
Parameters:
Name |
Type |
Argument |
Description |
pageNumber |
number
|
|
The page number for 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 |
|
<optional>
|
|
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:
Returns:
Returns a promise that resolves when all the annotations in the annotationList have been drawn
-
Type
-
Promise.<any>
-
enableRedaction(isEnabled)
-
A switch for turning on and off redaction tools
Parameters:
Name |
Type |
Description |
isEnabled |
boolean
|
A value for setting if redaction tools are enabled |
-
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.<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() |
|
Returns:
Returns a promise that resolves with the XFDF (XML) annotations as a string
-
Type
-
Promise.<string>
-
exportAnnotCommand()
-
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>
-
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
-
Annotations.Annotation
-
getAnnotationByMouseEvent(event)
-
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 |
Description |
event |
MouseEvent
|
A DOM mouse event. |
Returns:
An annotation object.
-
Type
-
Annotations.Annotation
-
getAnnotationCopy(annotation, options)
-
Returns a deep copy of the annotation
Parameters:
Name |
Type |
Description |
annotation |
Annotations.Annotation
|
An instance of Annotation to be copied. |
options |
Object
|
Options for this function
Properties
Name |
Type |
Description |
copyAssociatedLink |
boolean
|
Whether to make a deep copy of an associated link |
|
Returns:
a copy of the annotation, null if annotation cannot be copied
-
Type
-
Annotations.Annotation
-
-
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
-
Annotations.Annotation
-
getAnnotationsByMouseEvent(event)
-
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 |
Description |
event |
MouseEvent
|
A DOM mouse event. |
Returns:
An array of annotation objects.
-
Type
-
Array.<Annotations.Annotation>
-
getAnnotationsList()
-
Gets the list of all annotations managed by the AnnotationManager.
Returns:
An array of Annotations.
-
Type
-
Array.<Annotations.Annotation>
-
getAnnotCommand()
-
Gets an XML string specifying the added, modified and deleted annotations.
Added and modified annotations will have their XFDF representation included
while deleted annotations will only include their id.
- Deprecated:
-
- in favor of exportAnnotCommand
Returns:
Returns a promise that resolves to an XFDF command string
-
Type
-
Promise.<string>
-
getCopiedAnnotations()
-
Get copied annotations.
Returns:
returns array of copied annotations
-
Type
-
Array.<Annotations.Annotation>
-
getCurrentUser()
-
Returns the user name of the current user.
Returns:
The user name of the current user.
-
Type
-
string
-
getDisplayAuthor(annotation)
-
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 |
annotation |
object
|
Annotation object |
Returns:
The display author name
-
Type
-
string
-
getEditBoxManager()
-
Returns:
Returns an instance of EditorBoxManager
-
Type
-
CoreControls.EditBoxManager
-
getFieldManager()
-
Gets the associated field manager.
Returns:
-
Type
-
Annotations.Forms.FieldManager
-
getGroupAnnotations(annotation)
-
Gets all the annotations that are grouped with the passed in annotation, including said annotation.
Parameters:
Name |
Type |
Description |
annotation |
Annotations.Annotation
|
the annotation which will be used to get all other annotations from the same group |
Returns:
Gets all the annotations that are grouped with the passed in annotation, including said annotation.
-
Type
-
Array.<Annotations.Annotation>
-
getIsAdminUser()
-
Returns whether the current user has admin privileges.
Returns:
true if the current user is an admin, false otherwise.
-
Type
-
boolean
-
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
-
getReadOnly()
-
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
-
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 |
Annotations.Annotation
|
The annotation from which to find the root annotation in the reply chain |
Returns:
The root annotation
-
Type
-
Annotations.Annotation
-
getSelectedAnnotations()
-
Returns the list of selected annotations.
Returns:
An array of selected annotations.
-
Type
-
Array.<Annotations.Annotation>
-
-
Gets the associated widget editing manager.
Returns:
Returns an instance of WidgetEditingManager
-
Type
-
CoreControls.WidgetEditingManager
-
groupAnnotations(primaryAnnotation, annotations)
-
Groups an array of annotations
Parameters:
-
hasAnnotation(annotation)
-
Determines if the specified annotation exists in the managed list of annotations.
Parameters:
-
hideAnnotation(annot)
-
Hides the specified annotation.
Parameters:
-
hideAnnotations(annots)
-
Hides all of the annotations in the list
Parameters:
-
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 |
Annotations.Annotation
|
Array.<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>
-
importAnnotCommand(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.<Annotations.Annotation>>
-
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:
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:
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
-
-
Returns whether freeform rotation is enabled for annotations.
Returns:
true if freeform rotation is enabled, false otherwise.
-
Type
-
boolean
-
jumpToAnnotation(annotation)
-
Jumps to the page of the annotation and if it isn't visible then centers it in the window.
Parameters:
-
off( [type] [, fn])
-
Remove a handler of the given event name
Parameters:
Name |
Type |
Argument |
Description |
type |
string
|
number
|
<optional>
|
The name of the event to remove the handler of.
If type is undefined, all the handlers of the object will be removed |
fn |
function
|
<optional>
|
The handler associated with this event to be removed.
If fn is undefined, all the handlers of the given event name will be removed |
- Inherited From:
-
Returns:
Returns the object that 'off' is being called on
-
Type
-
object
Example
annotManager.off();
annotManager.off('annotationChanged');
annotManager.off('annotationChanged', fn);
-
on(type, fn)
-
Add a handler to the given event name
Parameters:
Name |
Type |
Description |
type |
string
|
number
|
The name of the event to listen to |
fn |
function
|
The handler to be called when the event is triggered |
- Inherited From:
-
Returns:
Returns the object that 'on' is being called on
-
Type
-
object
Example
annotManager.on('annotationChanged', (annotations, action) => {
...
});
-
one(type, fn)
-
Same as 'on' except the handler will be called only once
Parameters:
Name |
Type |
Description |
type |
string
|
number
|
The name of the event to listen to |
fn |
function
|
The handler to be called when the event is triggered |
- Inherited From:
-
Returns:
Returns the object that 'one' is being called on
-
Type
-
object
Example
annotManager.one('annotationChanged', (annotations, action) => {
...
});
-
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 |
-
redrawAnnotation(annotation)
-
Redraws the specified annotation.
Note that the entire annotation canvas for the page will be redrawn.
Parameters:
-
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 |
Annotations.Annotation
|
the class (constructor) of the annotation |
Returns:
true if registration was successful
-
Type
-
Boolean
-
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:
-
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:
-
-
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 |
CoreControls.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 the annotation object and should return the display name for the UI. |
Example
annotManager.setAnnotationDisplayAuthorMap((annotation) => {
if (annotation.Id === '1') {
return 'John';
} else {
return 'Guest';
}
});
-
setAnnotationStyles(annotation, newStyles)
-
Set the styles for the annotation
Parameters:
Name |
Type |
Description |
annotation |
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. |
-
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:
-
-
Sets whether the annotations will have freeform rotation enabled.
Parameters:
Name |
Type |
Description |
freeformRotationEnabled |
boolean
|
true if freeform rotation should be enabled, false otherwise. |
-
setIsAdminUser(isAdminUser)
-
Sets whether the current user is an admin user.
Parameters:
Name |
Type |
Description |
isAdminUser |
boolean
|
true if the current user is an admin, false otherwise. |
-
setNoteContents(annotation, text)
-
Sets the value of the note for the specified annotation.
Parameters:
Name |
Type |
Description |
annotation |
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. |
-
setReadOnly(readOnly)
-
Sets whether the viewer is currently in read-only mode.
Parameters:
Name |
Type |
Description |
readOnly |
boolean
|
true if the viewer is in read-only mode, false otherwise. |
-
setRedrawThrottle(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 |
-
-
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. |
-
showAnnotation(annot)
-
Shows the annotation
Parameters:
-
showAnnotations(annots)
-
Shows all of the annotations in the list
Parameters:
-
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
annotManager.trigger('annotationChanged');
annotManager.trigger('annotationChanged', [[annotation], 'add', {}]);
-
ungroupAnnotations(annotations)
-
Ungroups an array of annotations
Parameters:
-
updateAnnotation(annotation)
-
Redraws the annotations on the same page as the specified annotation if the annotation has been added.
Parameters:
-
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 |
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
-
Annotations.StickyAnnotation
-
updateCopiedAnnotations()
-
Copies the currently selected annotations.