Class: FreeTextAnnotation

Annotations. FreeTextAnnotation


new FreeTextAnnotation()

Represents a free text annotation.

Properties:
Name Type Description
TextColor Annotations.Color

The color of the text in the annotation

Font string

The font to use for the annotation's text

FontSize string

The font size to use for the annotation's text, specified like a CSS font size

TextAlign string

The horizontal alignment of the annotation's text (left, right, center)

EXPORT_CALCULATED_FONT_SIZE boolean

Whether to export calculated font size for auto-sized fonts (default is true)

Extends

Methods


addPathPoint(x, y)

Adds a point to the path

Parameters:
Name Type Description
x number

The x coordinate of the point

y number

The y coordinate of the point

Inherited From:

adjustRect()

Recalculate the width and height of the annotation

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:

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:

getBottom()

Gets the bottommost y position measured in page coordinates.

Inherited From:
Deprecated:
  • Since 1.7
Returns:
Type
number

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

getCustom()

Gets the custom value set by setCustom

Inherited From:
Returns:

The custom value

Type
*

getGroupedChildren()

Gets the list of group children to this annotation.

Inherited From:
Returns:

The list of group children

Type
Array

getHeight()

Gets the height of the annotation.

Inherited From:
Returns:

the height of the annotation.

Type
number

getIntent()

Gets the intent of the FreeText annotation e.g. FreeTextCallout

Returns:

The intent of the annotation

Type
string

getLeft()

Gets the leftmost x position measured in page coordinates.

Inherited From:
Deprecated:
  • Since 1.7
Returns:
Type
number

getPadding()

Get the rectangle difference of the annotation bounding rect and the text rect

Returns:

the rectangle difference

Type
Annotations.Rect

getPageNumber()

Gets the page number of the annotation. Note: page number starts from 1.

Inherited From:
Returns:

The annotation's page number

Type
number

getPath()

Gets the path array

Inherited From:
Returns:

The array of path points

Type
array

getPathPoint(index)

Gets the point in the path at the specified index

Parameters:
Name Type Description
index number

The index in the path array

Inherited From:
Returns:

The path point as an object with x and y properties

Type
object

getRect()

Get annotation bounding rectangle

Inherited From:
Returns:
Type
Annotations.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

getRight()

Gets the rightmost x position measured in page coordinates.

Inherited From:
Deprecated:
  • Since 1.7
Returns:
Type
number

getStartStyle()

Gets the start style of the line. Only applicable for callout annotations

Returns:

The start style

Type
string

getTop()

Gets the topmost y position measured in page coordinates.

Inherited From:
Deprecated:
  • Since 1.7
Returns:
Type
number

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

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

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

isVisible()

Whether the annotation is visible on the document or not. 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

Type
boolean

popPath()

Removes the last point from the path

Inherited From:

render(container, am, zoom)

Render the element's other features, if any. This can be used, for example, for HTML rendering

Parameters:
Name Type Description
container
am
zoom
Inherited From:

resize(rect)

Resize the annotation based on a new given Annotations.Rect. Use this method instead of setRect when internal properties (other than x, y, width and height) need to be modified on move/resize.

Parameters:
Name Type Description
rect Annotations.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

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

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:

setCustom(value)

Sets a custom value on the annotation.

Parameters:
Name Type Description
value *

Any custom value

Inherited From:

setHeight(value)

Sets the height of the annotation.

Parameters:
Name Type Description
value number

the height of the annotation.

Inherited From:

setIntent(intent)

Sets the intent of the FreeText annotation

Parameters:
Name Type Description
intent string

The new intent for the annotation


setPadding(rect)

Sets the rectangle difference of the annotation bounding rect and the text rect

Parameters:
Name Type Description
rect Annotations.Rect

The new rectangle difference


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:

setPathPoint(index, x, y)

Sets the path point at a specific index

Parameters:
Name Type Description
index number

The index in the path array to set

x number

The x coordinate of the point

y number

The y coordinate of the point

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. Use setRectWithNormalization instead of setRect if you want to reverse any wrong-way-round coordinates instead of ignoring them.

Parameters:
Name Type Description
rect Annotations.Rect

the new bounding rectangle

Inherited From:

setStartStyle(startStyle)

Sets the start style of the line. Only applicable for callout annotations.

Parameters:
Name Type Description
startStyle string

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

Sets the y position measured in page coordinates.

Parameters:
Type Description
number
Inherited From:

unrender()

Destroys any non-canvas elements

Inherited From: