Class: LineAnnotation

Core.Annotations. LineAnnotation


new LineAnnotation( [initializer])

Represents a line annotation.
Parameters:
Name Type Argument Description
initializer object <optional>
A map of values to auto-initialize certain properties of the annotation. You can only initialize properties defined on the annotation under the Members section (unless specified otherwise).

Extends

Members


<static> CaptionSnapPositions

Properties:
Name Type Description
START string Indicates the caption is snapped to start point of measurement annotation.
CENTER string Indicates the caption is snapped to center point of measurement annotation.
END string Indicates the caption is snapped to end point of measurement annotation.

Author

The author of the annotation.
Inherited From:

Color

Gets or sets the annotation's stroke color.
Inherited From:

Dashes

Gets or sets the border dash style of an annotation. e.g '3' or '3,3'

DateCreated

Gets or sets the date the annotation was created.
Inherited From:

DateModified

Gets or sets the date that the annotation was last modified.
Inherited From:

DisplayFormat

Gets or sets the annotation's measurement display format.
Example
WebViewer(...)
  .then(function(instance) {
    const { annotationManager, Annotations } = instance.Core;
    const measurementAnnotation = annotationManager.getAnnotationsList()[0]
    const measurementDisplayFormats = Annotations.Annotation.MeasurementDisplayFormats
     measurementAnnotation.DisplayFormat = measurementDisplayFormats.FRACTION
  });

DisplayUnits

Gets or sets the annotation's measurement display units.
Example
WebViewer(...)
  .then(function(instance) {
    const { annotationManager, Annotations } = instance.Core;
    const measurementAnnotation = annotationManager.getAnnotationsList()[0]
    const measurementUnits = Annotations.Annotation.MeasurementUnits
     measurementAnnotation.DisplayUnits = [measurementUnits.FT, measurementUnits.IN]
  });

elementName

Gets or sets the name of the annotation element in XFDF.

This property cannot be initialized through the initializer.

Inherited From:

End

Gets or sets the end point of the line.

FillColor

Gets or sets the color of the annotation's interior.
Inherited From:

Height

Gets or sets the height of the annotation.
Inherited From:

Hidden

Gets or sets whether the annotation is hidden.
Inherited From:

Id

A unique identifier for the annotation. Corresponds to the name attribute in XFDF.
Inherited From:

InReplyTo

The Id of the annotation that this annotation is replying to or the parent annotation it is grouped with.
Inherited From:

Invisible

Gets or sets whether the annotation is invisible, only if it is an unknown annotation type. Generally for hiding annotations you should use "Hidden".
Inherited From:

IsAdded

Gets or sets whether the annotation has been added since the last time the AnnotCommand was retrieved.
Inherited From:

IsClickableOutsideRect

Gets or sets whether any parts of the annotation drawn outside of the rect are clickable.
Inherited From:

IsDeleted

Gets or sets whether the annotation has been deleted since the last time the AnnotCommand was retrieved.
Inherited From:

IsHoverable

Gets or sets whether the annotation is hoverable or not. If it is hoverable then the IsHovering property will be true on the annotation when it is currently being hovered.
Inherited From:

IsModified

Gets or sets whether the annotation has been modified since the last time the AnnotCommand was retrieved.
Inherited From:

Listable

Gets or sets whether the annotation should be listed in annotation lists. If set to false the annotation also will not be selectable.
Inherited From:

Locked

Gets or sets whether the annotation is locked or not. If it's locked it can't be edited or deleted, but the note can be edited.
Inherited From:

LockedContents

Gets or sets whether the annotation contents are locked or not. If the contents are locked then note can't be edited but the annotation can be edited or deleted.
Inherited From:

MaintainAspectRatio

Gets or sets if the annotation maintains aspect ratio when being resized.
Inherited From:

NoDelete

Gets or sets if this annotation can be deleted.
Inherited From:

NoMove

Gets or sets whether or not the annotation can be moved.
Inherited From:

NoResize

Gets or sets if this annotation can be resized by the user.
Inherited From:

NoRotate

Gets or sets if this annotation rotates with the page.
Inherited From:

NoView

Gets or sets whether the annotation is visible on the screen. Differs from Hidden in that it can still be printed if the print flag is set.
Inherited From:

NoZoom

Gets or sets if this annotation scales with the page.
Inherited From:

Opacity

Gets or sets the opacity of the annotation.
Inherited From:

PageNumber

Gets or sets the page number of a document that the annotation appears on.
Inherited From:

Precision

Gets or sets the annotation's precision from its measure dictionary.
Example
WebViewer(...)
  .then(function(instance) {
    const { annotationManager, Annotations } = instance.Core;
    const measurementAnnotation = annotationManager.getAnnotationsList()[0]
    const measurementDisplayFormats = Annotations.Annotation.MeasurementDisplayFormats
     measurementAnnotation.DisplayFormat = measurementDisplayFormats.FRACTION
  });

Printable

Gets or sets whether the annotation should be displayed when printing the page.
Inherited From:

ReadOnly

Gets or sets whether the annotation is readonly or not. If it's readonly it can't be edited or deleted.
Inherited From:

ReplyType

The type of reply.
Inherited From:

Rotation

Gets or sets the annotation's clockwise rotation in degrees. Valid values are 0, 90, 180 and 270. Only applies to Stamp, FreeText and Caret annotations.
Inherited From:

RotationControlEnabled

Enables or disables the annotation's rotation control.
Inherited From:

Scale

Gets or sets the annotation's scale from its measure dictionary.

selectionModel

Gets or sets a selection model constructor for how an annotation gets selected.
Inherited From:

Start

Gets or sets the start point of the line.

StrokeColor

Gets or sets the color of the annotation's stroke.
Inherited From:

StrokeThickness

Gets or sets the width of the annotation's stroke outline.
Inherited From:

Style

Gets or sets the border style of an annotation. e.g Solid, Cloudy

Subject

Represents the subject of the annotation. Default is the annotation's type.
Inherited From:

System

Gets or sets the annotation's system (Metric, Imperial, Typographic).
Example
WebViewer(...)
  .then(function(instance) {
    const { annotationManager, Annotations } = instance.Core;
    const measurementAnnotation = annotationManager.getAnnotationsList()[0]
    const measurementSystems = Annotations.Annotation.MeasurementSystems
     measurementAnnotation.System = measurementSystems.METRIC

ToggleNoView

Gets or sets whether the ToggleNoView flag is set on the annotation.
Inherited From:

ToolName

The name of the tool that is used to create this annotation.
Inherited From:

ViewState

Gets or sets the viewer state (zoom, rotation, etc) that is associated with the annotation. This state can then be restored in the viewer at a later time.
Inherited From:

Width

Gets or sets the width of the annotation.
Inherited From:

X

Gets or sets the annotation's x-axis position.
Inherited From:

Y

Gets or sets the annotation's y-axis position.
Inherited From:

Methods


addCustomAppearance(doc [, options])

Adds a custom appearance to the annotation so that the annotation appears like the specified PDF page or object in the PDF page. This appearance will be used instead of the default WebViewer drawing of the annotation.
Parameters:
Name Type Argument Description
doc Core.Document the PDF document object.
options object <optional>
An object that can contain the following optional parameters.
Properties
Name Type Argument Default Description
pageNumber string <optional>
1 Page number of source document to use for custom appearance.
objnum string <optional>
The object number from the appearance document.
gennum string <optional>
The generation number from the appearance document.
transparentBackground string <optional>
Transparent background, default is true.
Inherited From:

adjustRect()

Adjusts the annotation's bounding rectangle to take into account changes to the annotation e.g. stroke thickness, start/end points, etc
Inherited From:

deleteCustomData(key)

Deletes custom data associated with the given key.
Parameters:
Name Type Description
key string The key for which to delete the associated data.
Inherited From:

deserialize(element, pageMatrix)

Deserializes the xml element into the annotation
Parameters:
Name Type Description
element Element an xml element representing the annotation
pageMatrix object the page matrix used to convert PDF coordinates to XOD coordinates.
Inherited From:

disableRotationControl()

Disables the rotation control for the annotation
Inherited From:

draw(ctx, pageMatrix)

Draws the annotation on the provide canvas context, relative to the page. The point (0,0) coresponds to the top left corner of the page.
Parameters:
Name Type Description
ctx CanvasRenderingContext2D The canvas context prepared to be drawn on.
pageMatrix object The page matrix for the page that the annotation is on. You can get this object by calling getPageMatrix on the document object.
Inherited From:

enableRotationControl()

Enables the rotation control for the annotation
Inherited From:

getAngle()

Returns the angle in radians from the X axis from start point to end point
Returns:
The angle in radians
Type
number

getAssociatedNumber()

Gets the number associated with this annotation, if any.
Inherited From:
See:
Returns:
The number associated with this annotation. If no number is associated then undefined is returned.
Type
number | undefined

getAttachments()

Gets the attachments of the annotation.
Inherited From:
Returns:
Type
Array.<Core.Annotations.Annotation.AnnotationAttachment>

getCaptionSnapPosition()

Get the current caption snap position.
See:
Returns:
Returns the current caption snap position.
Type
Core.Annotations.LineAnnotation.CaptionSnapPositions

getCenterLeaderPoint()

Returns the leader point located at the center (midpoint) of measurement line.
Deprecated:
Returns:
Center (midpoint) of measurement line.
Type
Core.Math.Point

getContentEditAnnotationId()

Returns the Content Annotation Id associated with a FreeText annotation that is used for inline editing, if there is one.
Inherited From:
Returns:
Type
string

getContentEditingFormat()

Returns the content editing format for the content editing placeholder. These are used to determine properties for inline editing styles.
Inherited From:
Returns:
The content editing format
Type
Core.Annotations.Annotation.ContentEditingFormat

getContentEditType()

Returns the content edit type, if there is one. Only applicable to content edit placeholder annotations.
Inherited From:
Returns:
Type
string

getContents()

Gets the text content for the annotation. Contents may be displayed in an annotation's popup or directly on the page (in the case of FreeTextAnnotation).
Inherited From:
Returns:
the text content for the annotation.
Type
string

getContentStyleProperties()

Returns the content style properties for the content editing placeholder
Inherited From:
Returns:
The content style properties
Type
Core.Annotations.Annotation.ContentStyleProperties

getCustomData(key)

Returns custom data associated with the given key.
Parameters:
Name Type Description
key string The key for which to retrieve the associated data.
Inherited From:
Returns:
value The custom data. If no data is available an empty string is returned.
Type
string

getEndPoint()

Gets the ending point of the line
Returns:
The end point
Type
Core.Math.Point

getEndStyle()

Gets the end style of the line
Returns:
The end style
Type
Core.Annotations.LineEndType

getFormFieldPlaceHolderType()

Returns what type of form field place holder it is, if it is a form field place holder
Inherited From:
Returns:
Form field place holder type as described by the Form Field Annotations enum
Type
string

getGroupedChildren()

Gets the list of group children to this annotation.
Inherited From:
Returns:
The list of group children
Type
Array.<Core.Annotations.Annotation>

getHeight()

Gets the height of the annotation.
Inherited From:
Returns:
the height of the annotation.
Type
number

getInternal()

Returns true if annotation is part of the original document, false otherwise.
Inherited From:
Deprecated:
  • Since version 8.3. Use isInternal instead.
Returns:
Whether the annotation is internal to the document or not
Type
boolean

getLeaderLineControlHandlePoint( [captionSnapPosition])

Returns the leader point located at the given caption snap position, in viewer coordinates.
Parameters:
Name Type Argument Description
captionSnapPosition Core.Annotations.LineAnnotation.CaptionSnapPositions <optional>
Indicates which side of measurement line to calculate leader point. Default value is whatever is returned from Core.Annotations.LineAnnotation#getCaptionSnapPosition.
Returns:
Position of leader control handle, in viewer coordinates.
Type
Core.Math.Point

getLeaderPoints()

Returns the leader points of this line
Returns:
An object containing the two leader points
Type
Core.Annotations.LineAnnotation.LeaderPoints

getLineLength()

Returns the length of the line in points
Returns:
The length in points
Type
number

getPageNumber()

Gets the page number of the annotation. Note: page number starts from 1.
Inherited From:
Returns:
The annotation's page number
Type
number

getRect()

Get annotation bounding rectangle
Inherited From:
Returns:
Type
Core.Math.Rect

getRectPadding()

Gets the padding that will be applied by default on the annotation's rectangle.
Inherited From:
Returns:
The amount of padding
Type
number

getReplies()

Gets the list of replies to this annotation.
Inherited From:
Returns:
The list of replies
Type
Array.<Core.Annotations.Annotation>

getRichTextStyle()

Gets the rich text style of the annotation.
Inherited From:
Returns:
the current rich text style
Type
Core.Annotations.Annotation.RichTextStyle

getStartPoint()

Gets the starting point of the line
Returns:
The start point
Type
Core.Math.Point

getStartStyle()

Gets the start style of the line
Returns:
The start style
Type
Core.Annotations.LineEndType

getStatus()

Gets the status of the annotation, and returns an empty string if no status set.
Inherited From:
Returns:
The last status update.
Type
string

getWidth()

Gets the width of the annotation.
Inherited From:
Returns:
the width of the annotation.
Type
number

getX()

Gets the x position measured in page coordinates of an annotation.
Inherited From:
Returns:
the x position
Type
number

getY()

Gets the y position measured in page coordinates.
Inherited From:
Returns:
Type
number

hasRotationControlEnabled()

Returns true if the rotation control is enabled for the annotation and false otherwise.
Inherited From:
Returns:
Type
boolean

isContentEditPlaceholder()

Returns whether the annotation is a content editing placeholder, which are annotations used as placeholders for content edit boxes when the content editing tool is active
Inherited From:
Returns:
Whether the annotation is a content edit placeholder or not
Type
boolean

isFormFieldPlaceholder()

Returns whether the annotation is a form field place holder annotation, which are annotations used as place holders for fields in the Form Field Creation mode
Inherited From:
Returns:
Type
boolean

isGrouped()

Gets whether the annotation is a child of a group
Inherited From:
Returns:
Returns true if the annotation is a child of a group, false otherwise.
Type
boolean

isInternal()

Returns true if annotation is part of the original document, false otherwise.
Inherited From:
Returns:
Whether the annotation is internal to the document or not
Type
boolean

isPrintVisible()

Whether the annotation is visible on the document or not **when printed**. If Hidden or if the annotation is a reply to another annotation then it won't be visible.
Inherited From:
Returns:
Whether the annotation is visible on the document or not when printed
Type
boolean

isReply()

Gets whether the annotation is a reply to another annotation.
Inherited From:
Returns:
Returns true if it does reply to another annotation, false otherwise.
Type
boolean

isUncommittedContentEditPlaceholder()

Returns whether the annotation is an uncommitted content editing placeholder, which are annotations that will become document content but were not committed yet.
Inherited From:
Returns:
Whether the annotation is an uncommitted content edit placeholder or not
Type
boolean

isVisible()

Whether the annotation is visible on the document or not **when viewing**. If the Hidden or NoView flags are set, or if the annotation is a reply to another annotation then it won't be visible.
Inherited From:
Returns:
Whether the annotation is visible on the document or not when viewing
Type
boolean

move(rect)

Move the annotation based on a new given Core.Math.Rect. Use this method instead of setRect when internal properties (other than x, y, width and height) need to be modified on move.
Parameters:
Name Type Description
rect Core.Math.Rect the new bounding rectangle
Inherited From:

removeCustomAppearance()

Removes the custom appearance of the annotation.
Inherited From:

resize(rect)

Resize the annotation based on a new given Core.Math.Rect. Use this method instead of setRect when internal properties (other than x, y, width and height) need to be modified on resize.
Parameters:
Name Type Description
rect Core.Math.Rect the new bounding rectangle
Inherited From:

resourcesLoaded()

Resolves when all required resources have finished loading. Currently only applicable to stamp annotations that use images.
Inherited From:
Returns:
A promise that resolves when the resources have finished loading
Type
Promise.<void>

serialize(element, pageMatrix)

Serialize the annotation to an xml element
Parameters:
Name Type Description
element Element an xml element representing the annotation
pageMatrix object the page matrix used to convert XOD coordinates to PDF coordinates.
Inherited From:
Returns:
the resulting xml element representing the annotation
Type
Element

setAssociatedNumber(number)

Sets the number to be associated with this annotation.
Parameters:
Name Type Description
number number The number to be associated with this annotation.
Inherited From:
See:

setAttachments(files)

Sets the attachments of the annotation.
Parameters:
Name Type Description
files Array.<(File|Core.Annotations.Annotation.AnnotationAttachment)> Array of attachments data.
Inherited From:

setCaptionSnapPosition(position)

Snaps the caption of a measurement line to given position.
Parameters:
Name Type Description
position Core.Annotations.LineAnnotation.CaptionSnapPositions Use one of the positions provided by CaptionSnapPositions

setContents(value)

Set the text content for the annotation. Note that this will not refresh the text in the UI.
Parameters:
Name Type Description
value string the text content to be set
Inherited From:

setCustomData(key, value)

Sets the custom data associated with the specified key.
Parameters:
Name Type Description
key string The key under which to store this custom data. Data will automatically be saved in the exported XFDF and merged into the PDF when downloading.
value string The custom data to store
Inherited From:

setEndPoint(x, y)

Sets the ending point of the line
Parameters:
Name Type Description
x number The x coordinate of the point
y number The y coordinate of the point

setEndStyle(endingStyle)

Sets the ending style of the line
Parameters:
Name Type Description
endingStyle Core.Annotations.LineEndType The ending style

setHeight(value)

Sets the height of the annotation.
Parameters:
Name Type Description
value number the height of the annotation.
Inherited From:

setLineLength(length)

Sets the length of a line
Parameters:
Name Type Description
length number The length in points

setModified( [shouldKeepAppearance])

Flags the annotation as modified if it has been before the last call to exportAnnotationCommand Removes the annotation's appearance if no parameter is passed Should be called if changing a custom property on the annotation that is used for serialization Otherwise the annotation will serialize the original deserialized value
Parameters:
Name Type Argument Description
shouldKeepAppearance boolean <optional>
If true then the annotation's appearance will be maintained
Inherited From:

setPageNumber(value)

Sets the page number of the annotation. Note: page numbers start from 1.
Parameters:
Name Type Description
value number the page number to be set
Inherited From:

setRect(rect)

Sets the size and location of the annotation's bounding rectangle. Use this method instead of resize when only the x, y, width and height needs to be modified. Beware: this method ignores coordinates if they are the wrong way around. (It hasn't been fixed for reasons of maintaining backward compatibility. use setRectWithNormalization instead if you want it to reverse the wrong-way-round coordinates instead of ignoring them.)
Parameters:
Name Type Description
rect Core.Math.Rect the new bounding rectangle
Inherited From:

setRectWithNormalization(rect)

Sets the size and location of the annotation's bounding rectangle. Use this method instead of resize when only the x, y, width and height needs to be modified. Use setRectWithNormalization instead of setRect if you want to reverse any wrong-way-round coordinates instead of ignoring them.
Parameters:
Name Type Description
rect Core.Math.Rect the new bounding rectangle
Inherited From:

setRichTextStyle(richTextStyle)

Sets the rich text style of the annotation. New style will replace the old one
Parameters:
Name Type Description
richTextStyle Core.Annotations.Annotation.RichTextStyle The new rich text style of the annotation
Inherited From:

setRotationControlEnabled(rotationControlEnabled)

Enables or disables the rotation control for the annotation
Parameters:
Name Type Description
rotationControlEnabled boolean true if the rotation control should be enabled
Inherited From:
Deprecated:
  • since version 8.0 Please use enableRotationControl or disableRotationControl instead

setStartPoint(x, y)

Sets the starting point of the line
Parameters:
Name Type Description
x number The x coordinate of the point
y number The y coordinate of the point

setStartStyle(startStyle)

Sets the start style of the line
Parameters:
Name Type Description
startStyle Core.Annotations.LineEndType The starting style

setStyles(ctx, pageMatrix)

Sets the annotation's styles for stroke, fill and opacity on the canvas context
Parameters:
Name Type Description
ctx CanvasRenderingContext2D A canvas context
pageMatrix object The transformation matrix for the page that the annotation is on
Inherited From:

setWidth(value)

Sets the width of the annotation.
Parameters:
Name Type Description
value number the width of the annotation.
Inherited From:

setX(value)

Sets the x position measured in page coordinates of an annotation.
Parameters:
Name Type Description
value number the x position
Inherited From:

setY(value)

Sets the y position measured in page coordinates.
Parameters:
Name Type Description
value number the y position
Inherited From:

updateRichTextStyle(object [, startIndex] [, endIndex])

Update the rich text style of the annotation. Can provide a range to set the which characters the style should apply to
Parameters:
Name Type Argument Description
object Core.Annotations.Annotation.StyleObject The new rich text style of the annotation
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
startIndex number <optional>
Starting character to apply style, if null apply to every character
endIndex number <optional>
Last character to apply style. If null, apply till end
Inherited From:

Type Definitions


LeaderPoints

the point in viewer coordinates
Type:
  • Object
Properties:
Name Type Description
Start Core.Math.Point the start point
End Core.Math.Point the end point