Show / Hide Table of Contents

# Class FileSpec

FileSpec corresponds to the PDF file specification object.

A PDF file can refer to the contents of another file by using a file specification, which can take either of the following forms:

- A simple file specification gives just the name of the target file in a standard format, independent of the naming conventions of any particular file system.
- A full file specification includes information related to one or more specific file systems.
- A URL reference.

Although the file designated by a file specification is normally external to the PDF file referring to it, it is also possible to embed the file allowing its contents to be stored or transmitted along with the PDF file. However, embedding a file does not change the presumption that it is external to (or separate from) the PDF file.

For more details on file specifications, please refer to Section 3.10, 'File Specifications' in the PDF Reference Manual.

##### Inheritance

object
FileSpec

##### Implements

IDisposable

##### Inherited Members

object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()

###### Namespace: pdftron.PDF

###### Assembly: PDFTronDotNet.dll

##### Syntax

    public class FileSpec : IDisposable

### 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 | A document to which the FileSpec should be added. To obtain SDFDoc from PDFDoc use PDFDoc.GetSDFDoc() or Obj.GetDoc().
string | path | The path to convert into a file specification.

##### 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 | A document to which the FileSpec should be added. To obtain SDF.Doc from PDFDoc use PDFDoc.GetSDFDoc() or Obj.GetDoc().
string | url | A uniform resource locator (URL) of the form defined in Internet RFC 1738, Uniform Resource Locators Specification.

##### Returns

Type | Description
--- | ---
FileSpec | newly created FileSpec object.

##### Exceptions

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

#### Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

##### Declaration

    public void Dispose()

#### Dispose(bool)

##### Declaration

    protected virtual void Dispose(bool disposing)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | disposing |

#### Equals(object)

##### Declaration

    public override bool Equals(object o)

##### Parameters

Type | Name | Description
--- | --- | ---
object | o | a given `Object`

##### Returns

Type | Description
--- | ---
bool | true, if equals to the given object

##### Overrides

object.Equals(object)

#### 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()

Releases all resources used by the FileSpec

##### Declaration

    protected ~FileSpec()

#### 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.

#### 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 `FileSpec` object

#### 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

#### op_Assign(FileSpec)

Assignment operator

##### Declaration

    public FileSpec op_Assign(FileSpec r)

##### Parameters

Type | Name | Description
--- | --- | ---
FileSpec | r | a given `FileSpec` object

##### Returns

Type | Description
--- | ---
FileSpec | a `FileSpec` object equals to the given object

### 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` object on the left of the operator
FileSpec | r | the`FileSpec` object on the right of the operator

##### Returns

Type | Description
--- | ---
bool | true, if both objects are equal

#### 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` object on the left of the operator
FileSpec | r | the`FileSpec` object on the right of the operator

##### Returns

Type | Description
--- | ---
bool | true, if both objects are not equal

### Implements

IDisposable