Class: FileAttachmentAnnotation

Annotations. FileAttachmentAnnotation


new FileAttachmentAnnotation()

Represents a file attachment annotation.
Properties:
Name Type Description
Icon string Gets or sets the icon for this fileattachment.

Extends

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 CoreControls.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.
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:

Associate a link with annotation. The associated links will be deleted with the annotation. You can associate multiple links with a single annotation.
Parameters:
Name Type Description
linkIds Array.<string> | string The link IDs to associate with the current annotation.
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:

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:

Returns all associated links with the annotation.
Inherited From:
Returns:
Link IDs associated with the annotation.
Type
Array.<string>

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

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
*

getFileData()

Gets the binary contents of the file attachment
Returns:
- A blob containing the binary contents of the file attachment
Type
Promise.<Blob>

getFileMetadata()

Returns:
Object containing important attributes of the file
Type
Annotations.FileAttachmentAnnotation.FileMetadata

getGroupedChildren()

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

getHeight()

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

getLeft()

Gets the leftmost x position measured in page coordinates.
Inherited From:
Deprecated:
  • Since 1.7
Returns:
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
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.<Annotations.Annotation>

getRichTextStyle()

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

getRight()

Gets the rightmost x position measured in page coordinates.
Inherited From:
Deprecated:
  • Since 1.7
Returns:
Type
number

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

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

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

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

removeCustomAppearance()

Removes the custom appearance of the annotation.
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.<any>

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:

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 * The custom data to store
Inherited From:

setFileData(data, mimeType, filename)

Sets the binary contents of the file attachment
Parameters:
Name Type Description
data ArrayBuffer An ArrayBuffer containing the binary contents of the fileattachment
mimeType string The mimeType of the data, for example application/pdf
filename string The filename for the attachment. This will be the name when the attachment is downloaded.
Returns:
A promise that resolves when the file data is set.
Type
Promise.<void>

setHeight(value)

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

setModified( [keepAppearance])

Flags the annotation as modified if it has been before the last call to exportAnnotCommand 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
keepAppearance 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 Annotations.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 Annotations.Rect the new bounding rectangle
Inherited From:

setRichTextStyle(richTextStyle)

Sets the rich text style of the annotation.
Parameters:
Name Type Description
richTextStyle Annotations.Annotation.RichTextStyle The new rich text style of the annotation
Inherited From:

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:

Removes all associated links with the annotation. Doesn't remove the underlying links.
Inherited From:

Type Definitions


FileMetadata

Type:
  • Object
Properties:
Name Type Description
mimeType string The mimetype attribute of the file
filename string The name of the file to be saved