Class FileSpec
Associates a file attachment with the document.
The file attachment will be displayed in the user interface of a viewer application (in Acrobat this is File Attachment tab). The function differs from Annot.CreateFileAttachment() because it associates the attachment with the whole document instead of an annotation on a specific page.
Implements
Inherited Members
Namespace: pdftron.PDF
Assembly: PDFNet.dll
Syntax
public class FileSpec : IDisposable
Examples
Another way to associate a file attachment with the document is using SDF::NameTree:
SDF.NameTree names = SDF.NameTree.Create(doc, "EmbeddedFiles");
names.put(file_key, file_keysz, embedded_file.GetSDFObj());
Constructors
FileSpec(Obj)
Create a FileSpec and initialize it using given Cos/SDF object.
Declaration
public FileSpec(Obj a)
Parameters
Type | Name | Description |
---|---|---|
Obj | a | given Cos/SDF object. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Methods
Create(SDFDoc, string)
Creates a file specification for the given file. By default, the specified file is embedded in PDF.
Declaration
public static FileSpec Create(SDFDoc doc, string path)
Parameters
Type | Name | Description |
---|---|---|
SDFDoc | doc |
|
string | path |
|
Returns
Type | Description |
---|---|
FileSpec | newly created FileSpec object. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Create(SDFDoc, string, bool)
Creates the.
Declaration
public static FileSpec Create(SDFDoc doc, string path, bool embed)
Parameters
Type | Name | Description |
---|---|---|
SDFDoc | doc | the doc |
string | path | the path |
bool | embed | the embed |
Returns
Type | Description |
---|---|
FileSpec | the file spec |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
CreateURL(SDFDoc, string)
Creates a URL file specification.
Declaration
public static FileSpec CreateURL(SDFDoc doc, string url)
Parameters
Type | Name | Description |
---|---|---|
SDFDoc | doc |
|
string | url |
|
Returns
Type | Description |
---|---|
FileSpec | newly created FileSpec object. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Dispose()
Releases all resources used by the FileSpec
Declaration
public override sealed void Dispose()
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Dispose(bool)
Declaration
[HandleProcessCorruptedStateExceptions]
protected virtual void Dispose(bool A_0)
Parameters
Type | Name | Description |
---|---|---|
bool | A_0 |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Equals(object)
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o | a given |
Returns
Type | Description |
---|---|
bool | true, if equals to the given object |
Overrides
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Export()
The function saves the data referenced by this FileSpec to an external file.
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)
Export.
Declaration
public bool Export(string save_as)
Parameters
Type | Name | Description |
---|---|---|
string | save_as | the save_as |
Returns
Type | Description |
---|---|
bool | true, if successful |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
~FileSpec()
Declaration
protected ~FileSpec()
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetFileData()
The function returns data referenced by this FileSpec.
Declaration
public Filter GetFileData()
Returns
Type | Description |
---|---|
Filter | A stream (filter) containing file data. If the file is embedded, the function returns a stream to the embedded file. If the file is not embedded, the function will return a stream to the external file. If the file is not embedded and the external file can't be found, the function returns NULL. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetFilePath()
Gets the file path.
Declaration
public string GetFilePath()
Returns
Type | Description |
---|---|
string | The file path for this file specification. If the FileSpec is a dictionary, a corresponding platform specific path is returned (DOS, Mac, or Unix). Otherwise the function returns the path represented in the form described in Section 3.10.1, 'File Specification Strings,' or , if the file system is URL, as a uniform resource locator (URL). If the FileSpec is not valid, an empty string is returned. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
GetSDFObj()
Gets the SDFObj.
Declaration
public Obj GetSDFObj()
Returns
Type | Description |
---|---|
Obj | The underlying SDF/Cos object. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
IsValid()
Checks if is valid.
Declaration
public bool IsValid()
Returns
Type | Description |
---|---|
bool | whether this is a valid (non-null) FileSpec. If the function returns false the underlying SDF/Cos object is null or is not valid and the FileSpec object should be treated as null as well. |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Set(FileSpec)
Sets value to the give FileSpec
object
Declaration
public void Set(FileSpec p)
Parameters
Type | Name | Description |
---|---|---|
FileSpec | p | a |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
SetDesc(string)
The functions sets the descriptive text associated with the file specification. This text is typically used in the EmbeddedFiles name tree.
Declaration
public void SetDesc(string desc)
Parameters
Type | Name | Description |
---|---|---|
string | desc | descriptive text |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
op_Assign(FileSpec)
Assignment operator
Declaration
public FileSpec op_Assign(FileSpec r)
Parameters
Type | Name | Description |
---|---|---|
FileSpec | r | a given |
Returns
Type | Description |
---|---|
FileSpec | a |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
Operators
operator ==(FileSpec, FileSpec)
Equality operator checks whether two FileSpec objects are the same
Declaration
public static bool operator ==(FileSpec l, FileSpec r)
Parameters
Type | Name | Description |
---|---|---|
FileSpec | l | the |
FileSpec | r | the |
Returns
Type | Description |
---|---|
bool | true, if both objects are equal |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |
operator !=(FileSpec, FileSpec)
Inequality operator checks whether two FileSpec objects are different
Declaration
public static bool operator !=(FileSpec l, FileSpec r)
Parameters
Type | Name | Description |
---|---|---|
FileSpec | l | the |
FileSpec | r | the |
Returns
Type | Description |
---|---|
bool | true, if both objects are not equal |
Exceptions
Type | Condition |
---|---|
PDFNetException | PDFNetException the PDFNet exception |