Class FileAttachment
A file attachment annotation (PDF 1.3) contains a reference to a file, which typically shall be embedded in the PDF file.
Implements
Inherited Members
Namespace: pdftron.PDF.Annots
Assembly: PDFNet.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.
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Dispose(bool)
Declaration
[HandleProcessCorruptedStateExceptions]
protected override void Dispose(bool A_0)
Parameters
Type | Name | Description |
---|---|---|
bool | A_0 |
Overrides
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()
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()
Sets the icon type to e_PushPin.
Declaration
public void SetIcon()
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 |