# Class: FileAttachmentAnnot

## PDFNet. FileAttachmentAnnot

#### new FileAttachmentAnnot()

  A file attachment annotation contains a reference to a file, which may be embedded in the PDF document.

### Methods

#### <static> createDefault(doc, pos, path)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `doc` | PDFNet.SDFDoc |
  `pos` | PDFNet.Rect |
  `path` | string |

  ##### Returns:

  A promise that resolves to an object of type: "FileAttachmentAnnot"

  Type
    PDFNet.FileAttachmentAnnot

#### <static> createFromObj(d)

  creates an FileAttachment annotation and initializes it using given Cos/SDF object. d Cos/SDF object used to initialize the FileAttachment annotation

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `d` | PDFNet.Obj | The Cos/SDF object to initialze the annotation with.

  ##### Returns:

  A promise that resolves to an object of type: "FileAttachmentAnnot"

  Type
    PDFNet.FileAttachmentAnnot

#### <static> createWithFileSpec(doc, pos, fs, icon_name)

  Creates a file attachment annotation.

  A file attachment annotation contains a reference to a file, which typically is embedded in the PDF file.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `doc` | PDFNet.SDFDoc | A document to which the annotation is added.
  `pos` | PDFNet.rect | A rectangle specifying the annotation's bounds, in user space coordinates.
  `fs` | PDFNet.FileSpec | a file specification object used to initialize the file attachment annotation.
  `icon_name` | number/enum |
      PDFNet.FileAttachmentAnnot.Icon = {
      	e_Graph : 0
      	e_PushPin : 1
      	e_Paperclip : 2
      	e_Tag : 3
      	e_Unknown : 4
      }
  The name of an icon to be used in displaying the annotation, default is PushPin.

  ##### Returns:

  A promise that resolves to a new file attachment annotation.

  Type
    PDFNet.FileAttachmentAnnot

#### createFromAnnot()

  ##### Returns:

  A promise that resolves to an object of type: "Annot"

  Type
    PDFNet.Annot

#### export(save_as)

  The function saves the data referenced by this File Attachment to an external file.

  If the file is embedded, the function saves the embedded file. If the file is not embedded, the function will copy the external file. If the file is not embedded and the external file can't be found, the function returns false.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `save_as` | string | An optional parameter indicating the filepath and filename where the data should be saved. If this parameter is not specified the function will attempt to save the file using FileSpec.GetFilePath().

  ##### Returns:

  A promise that resolves to true is the file was saved successfully, false otherwise.

  Type
    boolean

#### getFileSpec()

  ##### Returns:

  A promise that resolves to the file specification that contains a file reference or the embedded file data stream.

  Type
    PDFNet.FileSpec

#### getIcon()

  Default Value:
    - e_PushPin

  ##### Returns:

  A promise that resolves to the type the associated icon style.

  Type
    number

  ##### Example

      Return value enum:
      <pre>
      PDFNet.FileAttachmentAnnot.Icon = {
      	e_Graph : 0
      	e_PushPin : 1
      	e_Paperclip : 2
      	e_Tag : 3
      	e_Unknown : 4
      }
      </pre>

#### getIconName()

  Returns the name of the icon associated with the FileAttachment annotation.

  See:
    - GetIcon() GetIconName() returns the icon name as it appears in the annotation dictionary, while GetIcon() returns the same icon name converted to enumeration value.

  ##### Returns:

  A promise that resolves to a string denoting the name of the icon.

  Type
    string

#### setFileSpec(file)

  sets the file specification.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `file` | PDFNet.FileSpec | The file specification to associate with this annotation.. The file specification contains a file reference or the embedded file data stream.

#### setIcon(type)

  sets the icon style associated with FileAttachment annotation. (Optional)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `type` | number/enum |
      PDFNet.FileAttachmentAnnot.Icon = {
      	e_Graph : 0
      	e_PushPin : 1
      	e_Paperclip : 2
      	e_Tag : 3
      	e_Unknown : 4
      }
  icon style.

  Default Value:
    - e_PushPin

#### setIconName(iname)

  sets the name of the icon associated with the FileAttachment annotation. (Optional)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `iname` | string | A string.denoting the name of the icon.

  See:
    - SetIcon()

#### Search results