DL Logo

PDFileSpec Typedefs

PDFileSpec

Header: PDExpT.h:1123

Description

    The PDF file specification object. It is used to specify a file in an action (see PDAction). A file specification in a PDF file can take two forms:
  • A single platform-independent path.
  • A data structure containing one or more alternative ways to locate the file on different platforms.

PDFileSpec objects can be created from ASPathName objects or from Cos objects.

Syntax

typedef OPAQUE_64_BITS PDFileSpec;

Returned From

Used By

Used In

PDFileSpec Callback Signatures

PDFileSpecAcquireASPathProc

Header: PDExpT.h:1164

Description

A callback for PDFileSpecHandler. It aquires the ASPath corresponding to a file specification.

Related Methods

Syntax

ASPathName PDFileSpecAcquireASPathProc(void *fileSpecHandlerObj, PDFileSpec fileSpec, ASPathName relativeToThisPath);

Parameters

fileSpecHandlerObj
IN/OUT User-supplied data passed in the call to PDRegisterFileSpecHandler().
fileSpec
IN/OUT The PDFileSpec for which an ASPath is acquired.
relativeToThisPath
IN/OUT A path name relative to which the PDFileSpec is interpreted. If NULL, fileSpec is assumed to be an absolute path, not a relative path.

Returns

The ASPathName corresponding to the specified path.

Used In

PDFileSpecNewFromASPathProc

Header: PDExpT.h:1147

Description

A callback for PDFileSpecHandler. It creates a file specification from an ASPath.

Related Methods

Syntax

PDFileSpec PDFileSpecNewFromASPathProc(void *fileSpecHandlerObj, PDDoc pdDoc, ASPathName path, ASPathName relativeToThisPath);

Parameters

fileSpecHandlerObj
User-supplied data passed in the call to PDRegisterFileSpecHandler().
pdDoc
The PDDoc in which the file specification is created.
path
The ASPathName for which a corresponding file specification is created.
relativeToThisPath
A path name relative to which path is interpreted. If NULL, path is assumed to be an absolute path, not a relative path.

Returns

The file specification corresponding to the specified ASPathName.

Used In

PDLaunchActionProc

Header: PDExpT.h:1177

Description

(Optional) A callback for PDFileSpecHandler. It launches a specified file. It is called when the Acrobat viewer encounters a Launch (GoTo File) action. If this callback is NULL, no launch action is performed.

Syntax

ASBool PDLaunchActionProc(void *fileSpecHandlerObj, PDDoc pdDoc, PDAction pdAction);

Parameters

fileSpecHandlerObj
IN/OUT The registered PDFileSpecHandler.
pdDoc
IN/OUT The document containing the Launch action.
pdAction
IN/OUT The action dictionary.

Returns

true if the handler can perform the Launch, false otherwise.

Used In

PDFileSpec Structures

_t_PDFileSpecHandler

Header: PDExpT.h:1186

Description

A data structure that implements a file specification handler. It contains callbacks that implement the file specification handler's functions (converting from a file specification to an ASPathName, creating a new file specification from an ASPathName, and launching the specified file).

Syntax

struct _t_PDFileSpecHandler {
ASSize_t size;
Must be sizeof(PDFileSpecHandlerRec).
PDLaunchActionProc LaunchAction;
ASFileSys fileSys;
The file system that is to be used with this file specification handler.
} PDFileSpecHandlerRec, *PDFileSpecHandler;

Used By

PDFileSpec Functions

PDFileSpecAcquireASPath

Header: PDProcs.h:5280

Description

Acquires an ASPathName for the specified file specification and relative path.

Related Methods

Syntax

ASPathName PDFileSpecAcquireASPath(PDFileSpec fileSpec, ASPathName relativeToThisPath);

Parameters

fileSpec
IN/OUT The file specification for which an ASPathName is acquired.
relativeToThisPath
IN/OUT A path name relative to which the fileSpec is interpreted. If it is NULL, fileSpec is assumed to be an absolute, not a relative, path.

Returns

The ASPathName corresponding to fileSpec.

After you are done using the ASPathName, you must free it using ASFileSysReleasePath().

PDFileSpecAcquireASPathEx

Header: PDProcs.h:11458

Description

Acquires an ASPathName for the specified file specification and relative path.

Related Methods

Syntax

ASPathName PDFileSpecAcquireASPathEx(PDFileSpec fileSpec, ASFileSys relPathFileSys, ASPathName relativeToThisPath, ASFileSys *retFileSys, ASBool pathMustExist);

Parameters

fileSpec
IN/OUT The file specification for which an ASPathName is acquired.
relPathFileSys
The file system that owns relativeToThisPath.
relativeToThisPath
IN/OUT A path name relative to which the fileSpec is interpreted. If it is NULL, fileSpec is assumed to be an absolute, not a relative, path. If it is not NULL and fileSys and relPathFileSys are not the same, then an attempt is made to fabricate a relPathName in terms of fileSys, and if that is not possible, NULL is used.
retFileSys
IN/OUT The file system that owns the returned ASPathName.
pathMustExist
IN/OUT If it is true and the result ASPathName does not exist, then the return value is NULL.

Returns

The ASPathName corresponding to fileSpec.

After you are done using the ASPathName, you must free it using ASFileSysReleasePath().

PDFileSpecFromCosObj

Header: PDProcs.h:5249

Description

Converts an appropriate string or dictionary Cos object to a file specification. This method does not copy the object, but is instead the logical equivalent of a type cast.

Syntax

PDFileSpec PDFileSpecFromCosObj(CosObj obj);

Parameters

obj
IN/OUT The Cos object to convert to a file specification.

Returns

The file specification corresponding to obj.

Exceptions

is raised if the file specification is not valid, as determined by PDFileSpecIsValid().

PDFileSpecGetCosObj

Header: PDProcs.h:5294

Description

Gets the Cos object associated with a file specification. This method does not copy the object, but is instead the logical equivalent of a type cast.

Related Methods

Syntax

CosObj PDFileSpecGetCosObj(PDFileSpec fileSpec);

Parameters

fileSpec
IN/OUT The file specification whose Cos object is obtained.

Returns

The string or dictionary Cos object corresponding to the file specification.

PDFileSpecGetDIPath

Header: PDProcs.h:5353

Description

Gets the device-independent path name from a file specification.

Syntax

ASInt32 PDFileSpecGetDIPath(PDFileSpec fileSpec, char *buffer, ASInt32 bufLen);

Parameters

fileSpec
IN/OUT The file specification whose device-independent path name is obtained.
buffer
IN/OUT (Filled by the method) NULL-terminated device- independent path name. If buffer is NULL, the method simply returns the length of the path name.
bufLen
IN/OUT The length of buffer in bytes. If the device- independent path name is longer than this, only the first bufLen- 1 bytes are copied into buffer, plus a NULL at the end of the buffer.

Returns

The number of characters (excluding the NULL) copied into buffer.

PDFileSpecGetDIPathEx

Header: PDProcs.h:11473

Description

Gets the device-independent path name from a file specification.

Syntax

void PDFileSpecGetDIPathEx(PDFileSpec fileSpec, ASText diPath);

Parameters

fileSpec
IN The file specification whose device-independent path name is obtained.
diPath
IN/OUT An existing ASText object whose content is set to the path name obtained from from fileSpec.

PDFileSpecGetDoc

Header: PDProcs.h:5576

Description

Gets the PDDoc that contains fileSpec.

Syntax

PDDoc PDFileSpecGetDoc(PDFileSpec fileSpec);

Parameters

fileSpec
IN/OUT A PDFileSpec in a document.

Returns

A PDDoc or NULL if the file specification CosObj is not in a document.

PDFileSpecGetFileSys

Header: PDProcs.h:5261

Description

Gets the file system that services the specified file specification.

Related Methods

Syntax

ASFileSys PDFileSpecGetFileSys(PDFileSpec fileSpec);

Parameters

fileSpec
IN/OUT The file specification whose file system is obtained.

Returns

The file system that services fileSpec.

PDFileSpecGetFileSysName

Header: PDProcs.h:5596

Description

Gets the name of the file system that a PDFileSpec belongs to. For a simple fileSpec (string form), the name of the file system is the name of the document's file system if the CosObj that is the fileSpec is contained in a document. For a complex fileSpec (dictionary form) with an FS key, the name of the file system is the atom associated with the FS key.

The file system returned by PDFileSpecGetFileSys() is the file system that has registered a PDFileSpecHandler() for the file specification's file system name (if there is one), and is not necessarily the same as ASFileGetFileSysByName(PDFileSpecGetFileSysName(fileSpec));.

Related Methods

Syntax

ASAtom PDFileSpecGetFileSysName(PDFileSpec fileSpec);

Parameters

fileSpec

Returns

An ASAtom representing the file system of fileSpec.

PDFileSpecIsValid

Header: PDProcs.h:5306

Description

Tests whether a file specification is valid. This is intended only to ensure that the file specification has not been deleted, not to ensure that all necessary information is present and valid.

Syntax

ASBool PDFileSpecIsValid(PDFileSpec fileSpec);

Parameters

fileSpec
The file specification whose validity is tested.

Returns

true if fileSpec is valid, false otherwise.

PDFileSpecNewFromASPath

Header: PDProcs.h:5232

Description

Creates a new file specification from the specified ASPathName, using the PDFileSpecNewFromASPathProc() of the specified file system's file specification handler.

Related Methods

Syntax

PDFileSpec PDFileSpecNewFromASPath(PDDoc pdDoc, ASFileSys fileSys, ASPathName path, ASPathName relativeToThisPath);

Parameters

pdDoc
The document in which the new file specification will be used.
fileSys
A pointer to an ASFileSysRec specifying the file system responsible for the newly created file specification.
path
The path to convert into a file specification.
relativeToThisPath
A path name relative to which path is interpreted. If it is NULL, path is interpreted as an absolute path name, not a relative path name.

Returns

The newly created file spec, or an invalid file spec if the ASPathName cannot be converted to a PDFileSpec (use PDFileSpecIsValid() to test whether the conversion was successful).

PDFileSpecNewFromASPathEx

Header: PDProcs.h:11431

Description

Creates a new file specification from the specified ASPathName, using the PDFileSpecNewFromASPathProc() of the specified file system's file specification handler.

Related Methods

Syntax

PDFileSpec PDFileSpecNewFromASPathEx(PDDoc pdDoc, ASFileSys fileSys, ASPathName path, ASFileSys relPathFileSys, ASPathName relativeToThisPath);

Parameters

pdDoc
The document in which the new file specification will be used.
fileSys
A pointer to an ASFileSysRec specifying the file system responsible for the newly created file specification.
path
The path to convert into a file specification.
relPathFileSys
The file system that owns relativeToThisPath.
relativeToThisPath
A path name relative to which the fileSpec is interpreted. If it is NULL, fileSpec is assumed to be an absolute, not a relative, path. If it is not NULL and fileSys and relPathFileSys are not the same, then an attempt is made to fabricate a relPathName in terms of fileSys, and if that is not possible, NULL is used.

Returns

The newly created file specification, or an invalid file specification if the ASPathName cannot be converted to a PDFileSpec (use PDFileSpecIsValid() to test whether the conversion was successful).

PDRegisterFileSpecHandler

Header: PDProcs.h:5333

Description

Registers a new file specification handler with the Acrobat viewer. In version 3.0 and later of the Acrobat viewer, use the PDRegisterFileSpecHandlerByName method instead.

Syntax

void PDRegisterFileSpecHandler(ASFileSys contextFileSys, PDFileSpecHandler fileSpecHandler, void *fileSpecHandlerObj);

Parameters

contextFileSys
The file system that specifies the context in which the file specification handler is used. This is the file system on which the PDF document resides. It is sometimes necessary to use different file specification handlers depending on the file system in which the document is open. For example, when a document is opened in a web browser, the Acrobat viewer may use the browser's HTTP stack when it needs to use HTTP. When a document is opened outside of the browser, however, the Acrobat viewer must use a different HTTP stack.
fileSpecHandler
A pointer to a structure that contains the handler's callbacks. This structure must not be freed after calling PDRegisterFileSpecHandler().
fileSpecHandlerObj
A pointer to user-supplied data to pass to the file specification handler's callbacks each time they are called.

Exceptions

PDRegisterFileSpecHandlerByName

Header: PDProcs.h:5634

Description

Registers a new file specification handler with the Acrobat viewer. The viewer calls the appropriate file specification handler when it encounters a file specification in a PDF file. The appropriate file specification handler is the one whose specSysName matches the value of the FS key in the file specification and whose contextFileSys matches the file system on which the PDF file resides.

The file specification handler's file system, (passed as the fileSys field of fileSpecHandler), is used to obtain data from, or write data to, the file referred to by the file specification.

Related Methods

Syntax

void PDRegisterFileSpecHandlerByName(ASAtom specSysName, ASFileSys contextFileSys, PDFileSpecHandler fileSpecHandler, void *fileSpecHandlerObj);

Parameters

specSysName
The name (as an ASAtom) of a file system with which this file specification works.
contextFileSys
The file system that specifies the context in which the file specification handler is used. This is the file system on which the PDF document resides. It is sometimes necessary to use different file specification handlers depending on the file system in which the document is open. For example, when a document is opened in a web broswer, the Acrobat viewer may use the browser's HTTP stack when it needs to use HTTP. When a document is opened outside of the browser, however, the Acrobat viewer must use a different HTTP stack.
fileSpecHandler
A pointer to a structure that contains the handler's callbacks. This structure must not be freed after calling PDRegisterFileSpecHandlerByName().
fileSpecHandlerObj
A pointer to user-supplied data to pass to the file specification handler's callbacks each time they are called.

Exceptions