Show / Hide Table of Contents

# Class FileAttachment

A file attachment annotation (PDF 1.3) contains a reference to a file, which typically shall be embedded in the PDF file.

##### Inheritance

object
Annot
Markup
FileAttachment

##### Implements

IDisposable

##### Inherited Members

Markup.GetTitle()
Markup.SetTitle(string)
Markup.GetPopup()
Markup.SetPopup(Popup)
Markup.GetOpacity()
Markup.SetOpacity(double)
Markup.GetSubject()
Markup.SetSubject(string)
Markup.GetCreationDates()
Markup.SetCreationDates(Date)
Markup.GetBorderEffect()
Markup.SetBorderEffect(Markup.BorderEffect)
Markup.GetBorderEffectIntensity()
Markup.SetBorderEffectIntensity(double)
Markup.GetInteriorColor()
Markup.GetInteriorColorCompNum()
Markup.SetInteriorColor(ColorPt, int)
Markup.GetContentRect()
Markup.SetContentRect(Rect)
Markup.GetPadding()
Markup.SetPadding(Rect)
Markup.RotateAppearance(double)
Annot.Dispose()
Annot.Dispose(bool)
Annot.GetHandleInternal()
Annot.GetRefHandleInternal()
Annot.CreateInternal(IntPtr, object)
Annot.Create(SDFDoc, Annot.Type, Rect)
Annot.op_Assign(Annot)
Annot.Equals(object)
Annot.IsValid()
Annot.GetSDFObj()
Annot.GetType()
Annot.IsMarkup()
Annot.GetRect()
Annot.GetVisibleContentBox()
Annot.SetRect(Rect)
Annot.GetContents()
Annot.SetContents(string)
Annot.GetPage()
Annot.SetPage(Page)
Annot.GetUniqueID()
Annot.SetUniqueID(string)
Annot.GetDate()
Annot.SetDate(Date)
Annot.GetFlag(Annot.Flag)
Annot.SetFlag(Annot.Flag, bool)
Annot.GetBorderStyle()
Annot.SetBorderStyle(Annot.BorderStyle)
Annot.GetAppearance()
Annot.GetAppearance(Annot.AnnotationState)
Annot.GetAppearance(Annot.AnnotationState, string)
Annot.SetAppearance(Obj)
Annot.SetAppearance(Obj, Annot.AnnotationState)
Annot.SetAppearance(Obj, Annot.AnnotationState, string)
Annot.RemoveAppearance()
Annot.RemoveAppearance(Annot.AnnotationState)
Annot.RemoveAppearance(Annot.AnnotationState, string)
Annot.Flatten(Page)
Annot.GetActiveAppearanceState()
Annot.SetActiveAppearanceState(string)
Annot.GetColorAsRGB()
Annot.GetColorAsCMYK()
Annot.GetColorAsGray()
Annot.GetColorCompNum()
Annot.SetColor(ColorPt, int)
Annot.SetColor(ColorPt)
Annot.GetStructParent()
Annot.SetStructParent(int)
Annot.GetOptionalContent()
Annot.SetOptionalContent(Obj)
Annot.Resize(Rect)
Annot.GetRotation()
Annot.SetRotation(int)
Annot.RefreshAppearance()
Annot.GetCustomData(string)
Annot.SetCustomData(string, string)
Annot.DeleteCustomData(string)
object.Equals(object, object)
object.GetHashCode()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()

###### Namespace: pdftron.PDF.Annots

###### Assembly: PDFTronDotNet.dll

##### Syntax

    public class FileAttachment : Markup, IDisposable

### Constructors

#### FileAttachment(Annot)

Creates an FileAttachment annotation and initialize it using given annotation object.

##### Declaration

    public FileAttachment(Annot ann)

##### Parameters

Type | Name | Description
--- | --- | ---
Annot | ann | the annot

##### Remarks

The constructor does not copy any data, but is instead the logical equivalent of a type cast.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### FileAttachment(Obj)

Creates an FileAttachment annotation and initialize it using given Cos/SDF object.

##### Declaration

    public FileAttachment(Obj d)

##### Parameters

Type | Name | Description
--- | --- | ---
Obj | d | the d

##### Remarks

The constructor does not copy any data, but is instead the logical equivalent of a type cast.

### Methods

#### Create(SDFDoc, Rect, string)

Creates a file attachment annotation.

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

##### Declaration

    public static FileAttachment Create(SDFDoc doc, Rect pos, string path)

##### Parameters

Type | Name | Description
--- | --- | ---
SDFDoc | doc | A document to which the annotation is added.
Rect | pos | A rectangle specifying the annotation's bounds, in user space coordinates.
string | path | The path to the file which should be attached

##### Returns

Type | Description
--- | ---
FileAttachment | A new file attachment annotation.

##### Remarks

Note that FileAttachment icons can differ in their appearance dimensions, so you may want to match these Rectangle dimensions or the aspect ratio to avoid a squished or stretched appearance : e_Graph : 40 x 40 e_PushPin : 28 x 40 e_Paperclip : 14 x 34 e_Tag : 40 x 32

PDF Viewer applications should provide predefined icon appearances for at least the following standard names : Graph PushPin Paperclip Tag.Additional names may be supported as well.Default value : PushPin.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Create(SDFDoc, Rect, string, string)

Creates a file attachment annotation.

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

##### Declaration

    public static FileAttachment Create(SDFDoc doc, Rect pos, string path, string icon_name)

##### Parameters

Type | Name | Description
--- | --- | ---
SDFDoc | doc | A document to which the annotation is added.
Rect | pos | A rectangle specifying the annotation's bounds, in user space coordinates.
string | path | The path to the file which should be attached
string | icon_name | An icon to be used in displaying the annotation, default is PushPin.

##### Returns

Type | Description
--- | ---
FileAttachment | A new file attachment annotation.

##### Remarks

Note that FileAttachment icons can differ in their appearance dimensions, so you may want to match these Rectangle dimensions or the aspect ratio to avoid a squished or stretched appearance : e_Graph : 40 x 40 e_PushPin : 28 x 40 e_Paperclip : 14 x 34 e_Tag : 40 x 32

PDF Viewer applications should provide predefined icon appearances for at least the following standard names : Graph PushPin Paperclip Tag.Additional names may be supported as well.Default value : PushPin.

#### Export()

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.

##### Declaration

    public bool Export()

##### Returns

Type | Description
--- | ---
bool | true is the file was saved successfully, false otherwise.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Export(string)

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.

##### Declaration

    public bool Export(string save_as)

##### Parameters

Type | Name | Description
--- | --- | ---
string | save_as | 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

Type | Description
--- | ---
bool | true is the file was saved successfully, false otherwise.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### ~FileAttachment()

Releases all resources used by the FileAttachment

##### Declaration

    protected ~FileAttachment()

#### GetFileSpec()

Gets the file specification.

##### Declaration

    public FileSpec GetFileSpec()

##### Returns

Type | Description
--- | ---
FileSpec | The file associated with this annotation.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetIcon()

Gets the icon type as an entry of the enum "Icon".

##### Declaration

    public FileAttachment.Icon GetIcon()

##### Returns

Type | Description
--- | ---
FileAttachment.Icon | The enum "Icon" entry associated with this FileAttachment annotation.

##### Remarks

The entry specifies the name of an icon that shall be used in displaying the annotation. Conforming readers shall provide predefined icon appearances for at least the following standard names: GraphPushPin, PaperclipTag Additional names may be supported as well. Default value: PushPin. The annotation dictionary’s Appearance(AP) entry, if present, shall take precedence over the this entry

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetIconName()

Gets the icon type as a string.

##### Declaration

    public string GetIconName()

##### Returns

Type | Description
--- | ---
string | The string specifying the icon type associated with this FileAttachment annotation.

##### Remarks

the string spedifies the name of an icon that shall be used in displaying the annotation. Conforming readers shall provide predefined icon appearances for at least the following standard names: GraphPushPin, PaperclipTag Additional names may be supported as well. Default value: PushPin. The annotation dictionary’s Appearance(AP) entry, if present, shall take precedence over the this entry

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### SetFileSpec(FileSpec)

Sets the file specification.

##### Declaration

    public void SetFileSpec(FileSpec file)

##### Parameters

Type | Name | Description
--- | --- | ---
FileSpec | file | The file associated with this annotation.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### SetIcon(Icon)

Sets the icon type using an entry of the enum "Icon". (Optional)

##### Declaration

    public void SetIcon(FileAttachment.Icon type)

##### Parameters

Type | Name | Description
--- | --- | ---
FileAttachment.Icon | type | The enum "Icon" entry associated with this FileAttachment annotation.

##### Remarks

The entry specifies the name of an icon that shall be used in displaying the annotation. Conforming readers shall provide predefined icon appearances for at least the following standard names: GraphPushPin, PaperclipTag Additional names may be supported as well. Default value: PushPin. The annotation dictionary’s Appearance(AP) entry, if present, shall take precedence over the this entry

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### SetIconName(string)

Sets the icon type using a string. (Optional)

##### Declaration

    public void SetIconName(string icon)

##### Parameters

Type | Name | Description
--- | --- | ---
string | icon | The string specifying the icon type associated with this FileAttachment annotation.

##### Remarks

the string spedifies the name of an icon that shall be used in displaying the annotation. Conforming readers shall provide predefined icon appearances for at least the following standard names: GraphPushPin PaperclipTag Additional names may be supported as well. Default value: PushPin. The annotation dictionary’s Appearance(AP) entry, if present, shall take precedence over the this entry

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

### Implements

IDisposable