# Class: TextWidgetAnnotation

## Annotations. TextWidgetAnnotation

#### new TextWidgetAnnotation(field, options)

  Represents a Text Widget annotation. These include boxes and fields where text can be entered.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `field` | Annotations.Forms.Field |  | The field to associate with the widget
  `options` | object | <nullable> | A map of properties to set on the widget

### Extends

- Annotations.WidgetAnnotation

### Methods

#### addAction(trigger, action)

  Add a single action to a trigger.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `trigger` | string | The name of the trigger to which to add the action.
  `action` | Actions.Action | object | The action to add, or an object representing the desired properties (including a name)

  Inherited From:
    - Actions.Dispatcher#addAction

#### addActions(actions)

  Add the actions to the dispatcher so they run on next trigger, constructing them if necessary

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `actions` | object | The actions to add, as an object with triggers for keys and arrays of action-describing objects for values.

  Inherited From:
    - Actions.Dispatcher#addActions

#### addActionsFromXfdf(widgetElement, pageMatrix)

  Read and instantiate actions from XFDF.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `widgetElement` | Element | The widget element to read from
  `pageMatrix` | XODText.Matrix2D | The widget's page's transormation matrix

  Inherited From:
    - Actions.Dispatcher#addActionsFromXfdf
  Deprecated:
    - Due to PDFInfo

#### 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:
    - Annotations.Annotation#adjustRect

#### 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:
    - Annotations.Annotation#deserialize

#### 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:
    - Annotations.Annotation#draw

#### getActions()

  Get all the actions associated with this dispatcher.

  Inherited From:
    - Actions.Dispatcher#getActions

  ##### Returns:

  The associated actions (in the same format as addActions)

  Type
    object

#### getBottom()

  Gets the bottommost y position measured in page coordinates.

  Inherited From:
    - Annotations.Annotation#getBottom
  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:
    - Annotations.Annotation#getContents

  ##### Returns:

  the text content for the annotation.

  Type
    string

#### getCustom()

  Gets the custom value set by setCustom

  Inherited From:
    - Annotations.Annotation#getCustom

  ##### Returns:

  The custom value

  Type
    *

#### getDocumentViewer()

  Get the associated DocumentViewer.

  Inherited From:
    - Actions.Dispatcher#getDocumentViewer

  ##### Returns:

  The associated DocumentViewer instance

  Type
    CoreControls.DocumentViewer

#### getField()

  Gets the widget's associated field.

  Inherited From:
    - Annotations.WidgetAnnotation#getField

  ##### Returns:

  The widget's field.

  Type
    Annotations.Forms.Field

#### getGroupedChildren()

  Gets the list of group children to this annotation.

  Inherited From:
    - Annotations.Annotation#getGroupedChildren

  ##### Returns:

  The list of group children

  Type
    Array

#### getHeight()

  Gets the height of the annotation.

  Inherited From:
    - Annotations.Annotation#getHeight

  ##### Returns:

  the height of the annotation.

  Type
    number

#### getLeft()

  Gets the leftmost x position measured in page coordinates.

  Inherited From:
    - Annotations.Annotation#getLeft
  Deprecated:
    - Since 1.7

  ##### Returns:

  Type
    number

#### getPageNumber()

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

  Inherited From:
    - Annotations.Annotation#getPageNumber

  ##### Returns:

  The annotation's page number

  Type
    number

#### getRect()

  Get annotation bounding rectangle

  Inherited From:
    - Annotations.Annotation#getRect

  ##### Returns:

  Type
    Annotations.Rect

#### getRectPadding()

  Gets the padding that will be applied by default on the annotation's rectangle.

  Inherited From:
    - Annotations.Annotation#getRectPadding

  ##### Returns:

  The amount of padding

  Type
    number

#### getReplies()

  Gets the list of replies to this annotation.

  Inherited From:
    - Annotations.Annotation#getReplies

  ##### Returns:

  The list of replies

  Type
    Array

#### getRight()

  Gets the rightmost x position measured in page coordinates.

  Inherited From:
    - Annotations.Annotation#getRight
  Deprecated:
    - Since 1.7

  ##### Returns:

  Type
    number

#### getTop()

  Gets the topmost y position measured in page coordinates.

  Inherited From:
    - Annotations.Annotation#getTop
  Deprecated:
    - Since 1.7

  ##### Returns:

  Type
    number

#### getValue()

  Get the widget's value.

  Inherited From:
    - Annotations.WidgetAnnotation#getValue

  ##### Returns:

  The widget's value (potentially formatted).

  Type
    string | number

#### getWidth()

  Gets the width of the annotation.

  Inherited From:
    - Annotations.Annotation#getWidth

  ##### Returns:

  the width of the annotation.

  Type
    number

#### getX()

  Gets the x position measured in page coordinates of an annotation.

  Inherited From:
    - Annotations.Annotation#getX

  ##### Returns:

  the x position

  Type
    number

#### getY()

  Gets the y position measured in page coordinates.

  Inherited From:
    - Annotations.Annotation#getY

  ##### Returns:

  Type
    number

#### isGrouped()

  Gets whether the annotation is a child of a group

  Inherited From:
    - Annotations.Annotation#isGrouped

  ##### 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:
    - Annotations.Annotation#isReply

  ##### 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:
    - Annotations.Annotation#isVisible

  ##### Returns:

  Whether the annotation is visible on the document or not

  Type
    boolean

#### 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:
    - Annotations.Annotation#render

#### 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:
    - Annotations.Annotation#resize

#### resourcesLoaded()

  Resolves when all required resources have finished loading. Currently only applicable to stamp annotations that use images.

  Inherited From:
    - Annotations.Annotation#resourcesLoaded

  ##### Returns:

  A promise that resolves when the resources have finished loading

  Type
    Promise

#### saveActionsToXfdf(widgetElement, pageMatrix, overrideElement)

  Save the actions associated with this Dispatcher to an XFDF DOM element.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `widgetElement` | Element |  | The element to which to write the actions
  `pageMatrix` | XODText.Matrix2D |  | The widget's page's transformation matrix
  `overrideElement` | Element | <nullable> | An optional other element to write to. If not provided, an OnActivation element will be added to widgetElement

  Inherited From:
    - Actions.Dispatcher#saveActionsToXfdf
  Deprecated:
    - Due to PDFInfo

#### 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:
    - Annotations.Annotation#serialize

  ##### Returns:

  the resulting xml element representing the annotation

  Type
    Element

#### set(options)

  Set all properties on this widget.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | Annotations.WidgetAnnotation | Annotations.WidgetSpec | The set of parameters to set

  Inherited From:
    - Annotations.WidgetAnnotation#set

#### 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:
    - Annotations.Annotation#setContents

#### setCustom(value)

  Sets a custom value on the annotation.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | * | Any custom value

  Inherited From:
    - Annotations.Annotation#setCustom

#### setDocumentViewer(documentViewer)

  Set the internal DocumentViewer reference, which is required for some actions to execute correctly.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `documentViewer` | CoreControls.DocumentViewer | The DocumentViewer instance

  Inherited From:
    - Actions.Dispatcher#setDocumentViewer

#### setField(field)

  Sets the widget's associated field.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `field` | Annotations.Forms.Field | The new field to associate with the widget.

  Inherited From:
    - Annotations.WidgetAnnotation#setField

#### setHeight(value)

  Sets the height of the annotation.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | number | the height of the annotation.

  Inherited From:
    - Annotations.Annotation#setHeight

#### 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:
    - Annotations.Annotation#setPageNumber

#### 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:
    - Annotations.Annotation#setRect

#### setValue(value)

  Set and format the widget's value.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `value` | string | number | <nullable> | The new value to set

  Inherited From:
    - Annotations.WidgetAnnotation#setValue

#### setWidth(value)

  Sets the width of the annotation.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | number | the width of the annotation.

  Inherited From:
    - Annotations.Annotation#setWidth

#### setX(value)

  Sets the x position measured in page coordinates of an annotation.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | number | the x position

  Inherited From:
    - Annotations.Annotation#setX

#### setY()

  Sets the y position measured in page coordinates.

  ##### Parameters:

  Type | Description
  --- | ---
  number |

  Inherited From:
    - Annotations.Annotation#setY

#### triggerAction(trigger, event)

  Trigger all the actions associated with the given trigger, passing the event provided.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `trigger` | string | The trigger to trigger
  `event` | Annotations.Forms.PDFJS.Event | The event to pass to each action

  Inherited From:
    - Actions.Dispatcher#triggerAction

#### unrender()

  Destroys any non-canvas elements

  Inherited From:
    - Annotations.Annotation#unrender

#### Search results