new Annotation()
The base class for all annotations
Properties:
Name | Type | Description |
---|---|---|
Author |
string | The author of the annotation. |
Custom |
* | Gets or sets a custom property on the annotation. |
DateModified |
Date | Gets or sets the date that the annotation was last modified. |
elementName |
string | Gets or sets the name of the annotation element in XFDF. |
Height |
number | Gets or sets the height of the annotation |
Hidden |
boolean | Gets or sets whether the annotation is hidden. |
Id |
string | A unique identifier for the annotation. Corresponds to the name attribute in XFDF. |
IsAdded |
boolean | Gets or sets whether the annotation has been added since the last time the AnnotCommand was retrieved. |
IsDeleted |
boolean | Gets or sets whether the annotation has been deleted since the last time the AnnotCommand was retrieved. |
IsModified |
boolean | Gets or sets whether the annotation has been modified since the last time the AnnotCommand was retrieved. |
Listable |
boolean | Gets or sets whether the annotation should be listed in annotation lists. |
NoMove |
boolean | Gets or sets whether or not the annotation can be moved |
NoResize |
boolean | Gets or sets if this annotation can be resized by the user. |
NoRotate |
boolean | Gets or sets if this annotation can be rotated. |
NoZoom |
boolean | Gets or sets if this annotation scales with the page. |
PageNumber |
number | Gets or sets the page number of a document that the annotation appears on. |
Subject |
string | Represents the subject of the annotation. Default is the annotation's type. |
Width |
number | Gets or sets the width of the annotation |
X |
number | Gets or sets the annotation's x-axis position. |
Y |
number | Gets or sets the annotation's y-axis position. |
exportContentsRichtext |
number | Whether the contents-richtext element should be exported when serializing to XFDF |
Methods
-
adjustRect()
-
Adjusts the annotation's bounding rectangle to take into account changes to the annotation e.g. stroke thickness, start/end points, etc
-
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.
-
draw(ctx)
-
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.
-
getBottom()
-
Gets the bottommost y position measured in page coordinates.
- 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).
Returns:
the text content for the annotation.
- Type
- string
-
getCustom()
-
Gets the custom value set by setCustom
Returns:
The custom value
- Type
- *
-
getFlag(flag)
-
Determine if the give flag is marked flagged
Parameters:
Name Type Description flag
number Returns:
- Type
- boolean
-
getHeight()
-
Gets the height of the annotation.
Returns:
the height of the annotation.
- Type
- number
-
getLeft()
-
Gets the leftmost x position measured in page coordinates.
- Deprecated:
-
- Since 1.7
Returns:
- Type
- number
-
getPageNumber()
-
Gets the page number of the annotation. Note: page number starts from 1.
Returns:
The annotation's page number
- Type
- number
-
getRect()
-
Get annotation bounding rectangle
Returns:
- Type
- Annotations.Rect
-
getRectPadding()
-
Gets the padding that will be applied by default on the annotation's rectangle.
Returns:
The amount of padding
- Type
- number
-
getReplies()
-
Gets the list of replies to this annotation.
Returns:
The list of replies
- Type
- Array
-
getRight()
-
Gets the rightmost x position measured in page coordinates.
- Deprecated:
-
- Since 1.7
Returns:
- Type
- number
-
getTop()
-
Gets the topmost y position measured in page coordinates.
- Deprecated:
-
- Since 1.7
Returns:
- Type
- number
-
getWidth()
-
Gets the width of the annotation.
Returns:
the width of the annotation.
- Type
- number
-
getX()
-
Gets the x position measured in page coordinates of an annotation.
Returns:
the x position
- Type
- number
-
getY()
-
Gets the y position measured in page coordinates.
Returns:
- Type
- number
-
isReply()
-
Gets whether the annotation is a reply to another annotation.
Returns:
Returns true if it does reply to another annotation, false otherwise.
- 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
-
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
-
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.
Returns:
the resulting xml element representing the annotation
- Type
- Element
-
setContents(the)
-
Set the text content for the annotation. Note that this will not refresh the text in the UI.
Parameters:
Name Type Description the
string text content to be set
-
setCustom(value)
-
Sets a custom value on the annotation.
Parameters:
Name Type Description value
* Any custom value
-
setFlag(flag, value)
-
Set the value of given Flag.
Parameters:
Name Type Description flag
number value
boolean -
setHeight(value)
-
Sets the height of the annotation.
Parameters:
Name Type Description value
number the height of the annotation.
-
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
-
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.
Parameters:
Name Type Description rect
Annotations.Rect the new bounding rectangle
-
setWidth(value)
-
Sets the width of the annotation.
Parameters:
Name Type Description value
number the width of the annotation.
-
setX(value)
-
Sets the x position measured in page coordinates of an annotation.
Parameters:
Name Type Description value
number the x position
-
setY()
-
Sets the y position measured in page coordinates.
Parameters:
Type Description number -
unrender()
-
Destroys any non-canvas elements