pdftron.PDF
Class FileSpec

java.lang.Object
  extended by pdftron.PDF.FileSpec

public class FileSpec
extends java.lang.Object

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.


Constructor Summary
FileSpec(Obj f)
          Create a FileSpec and initialize it using given Cos/SDF object.
 
Method Summary
static FileSpec __Create(long impl, java.lang.Object ref)
           
 long __GetHandle()
           
 java.lang.Object __GetRefHandle()
           
static FileSpec create(Doc doc, java.lang.String path)
          Creates a file specification for the given file.
static FileSpec create(Doc doc, java.lang.String path, boolean embed)
          Creates a file specification for the given file.
static FileSpec createURL(Doc doc, java.lang.String url)
          Creates a URL file specification.
 boolean equals(java.lang.Object d)
          Compares two FileSpec-s for equality.
 boolean export()
          The function saves the data referenced by this FileSpec to an external file.
 boolean export(java.lang.String save_as)
          The function saves the data referenced by this FileSpec to an external file.
 Filter getFileData()
          The function returns data referenced by this FileSpec.
 java.lang.String getFilePath()
          Get the file path.
 Obj getSDFObj()
          Get the SDFObj.
 int hashCode()
           
 boolean isValid()
          Checks if current FileSpec is valid.
 void setDesc(java.lang.String desc)
          The functions sets the descriptive text associated with the file specification.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSpec

public FileSpec(Obj f)
Create a FileSpec and initialize it using given Cos/SDF object.

Parameters:
f - the given Cos/SDF object
Note:
The constructor does not copy any data, but is instead the logical equivalent of a type cast.
Method Detail

create

public static FileSpec create(Doc doc,
                              java.lang.String path)
                       throws PDFNetException
Creates a file specification for the given file. The specified file is embedded in PDF.

Parameters:
doc - - A document to which the FileSpec should be added. To obtain SDFDoc from PDFDoc use PDFDoc::GetSDFDoc() or Obj::GetDoc().
path - - The path to convert into a file specification.
Returns:
newly created FileSpec object.
Throws:
PDFNetException

create

public static FileSpec create(Doc doc,
                              java.lang.String path,
                              boolean embed)
                       throws PDFNetException
Creates a file specification for the given file.

Parameters:
doc - A document to which the FileSpec should be added. To obtain SDFDoc from PDFDoc use PDFDoc.GetSDFDoc or Obj.GetDoc.
path - The path to convert into a file specification.
embed - A flag indicating whether to embed specified in the PDF. By default, all files are embedded.
Returns:
the newly created FileSpec object
Throws:
PDFNetException

createURL

public static FileSpec createURL(Doc doc,
                                 java.lang.String url)
                          throws PDFNetException
Creates a URL file specification.

Parameters:
doc - - A document to which the FileSpec should be added. To obtain SDF::Doc from PDFDoc use PDFDoc::GetSDFDoc() or Obj::GetDoc().
url - - A uniform resource locator (URL) of the form defined in Internet RFC 1738, Uniform Resource Locators Specification.
Returns:
newly created FileSpec object.
Throws:
PDFNetException

equals

public boolean equals(java.lang.Object d)
Compares two FileSpec-s for equality. The comparison will return true only if both annotations share the same underlying SDF/Cos object.

Overrides:
equals in class java.lang.Object
Parameters:
d - the d
Returns:
true, if successful

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isValid

public boolean isValid()
                throws PDFNetException
Checks if current FileSpec is valid.

Returns:
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.
Throws:
PDFNetException

export

public boolean export()
               throws PDFNetException
The function saves the data referenced by this FileSpec to an external file.

Returns:
true is the file was saved successfully, false otherwise.
Throws:
PDFNetException

export

public boolean export(java.lang.String save_as)
               throws PDFNetException
The function saves the data referenced by this FileSpec to an external file.

Parameters:
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:
true, if successful
Throws:
PDFNetException

getFileData

public Filter getFileData()
                   throws PDFNetException
The function returns data referenced by this FileSpec.

Returns:
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.
Throws:
PDFNetException

getFilePath

public java.lang.String getFilePath()
                             throws PDFNetException
Get the file path.

Returns:
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.
Throws:
PDFNetException

setDesc

public void setDesc(java.lang.String desc)
             throws PDFNetException
The functions sets the descriptive text associated with the file specification. This test is typically used in the EmbeddedFiles name tree.

Parameters:
desc - the new description
Throws:
PDFNetException

getSDFObj

public Obj getSDFObj()
Get the SDFObj.

Returns:
The underlying SDF/Cos object.

__Create

public static FileSpec __Create(long impl,
                                java.lang.Object ref)

__GetHandle

public long __GetHandle()

__GetRefHandle

public java.lang.Object __GetRefHandle()


© 2002-2011 PDFTron Systems Inc.