foxit.pdf.Attachments Class Reference
Inheritance diagram for foxit.pdf.Attachments:
foxit.common.Base

Public Member Functions

 Attachments (foxit.pdf.PDFDoc doc, PDFNameTree nametree)
 Constructor, with parameters. from a PDF document object and an EmbeddedFiles name tree (if any).
More...
 
 Attachments (Attachments other)
 Constructor, with another Attachments object.

 
bool AddEmbeddedFile (string key, FileSpec file_spec)
 Add an embedded attachment (as FileSpec object) with new key name.
More...
 
bool AddFromFilePath (string key, string file_path)
 Add a new attachment from specified file path with new key name.
More...
 
bool ExtractEmbeddedFileTo (string key, string dst_file_path)
 Extract an attachment and save it to a specified file path.
More...
 
int GetCount ()
 Get the count of attachments.
More...
 
FileSpec GetEmbeddedFile (string key)
 Get the attachment (as FileSpec object) of a specified key.
More...
 
string GetKey (int index)
 Get the key of an attachment defined in the EmbeddedFiles name tree, by index.
More...
 
PDFNameTree GetNameTree ()
 Get the EmbeddedFiles name tree.
More...
 
bool IsEmpty ()
 Check whether current object is empty or not.
More...
 
bool RemoveAllEmbeddedFiles ()
 Remove all attachments.
More...
 
bool RemoveEmbeddedFile (string key)
 Remove an attachment by key.
More...
 
bool SetEmbeddedFile (string key, FileSpec file_spec)
 Set an embedded attachment (as FileSpec object) for a specified key.
More...
 

Detailed Description

In application, document's embedded files are known as PDF attachments. This class offers a more convenient way, than class objects::PDFNameTree, to get/set embedded files (also known as attachment files) in EmbeddedFiles name tree of a PDF document.

See also
pdf::PDFDoc
objects::PDFNameTree

Constructor & Destructor Documentation

◆ Attachments()

foxit.pdf.Attachments.Attachments ( foxit.pdf.PDFDoc  doc,
PDFNameTree  nametree 
)
inline

Constructor, with parameters. from a PDF document object and an EmbeddedFiles name tree (if any).


If no name tree object is specified, this function will construct the Attachments object from PDF document: if there exists EmbeddedFiles name tree in the PDF document, this function is just to construct an Attachments object to be associated with the name tree; If there is no such name tree in PDF document, the constructed Attachments object can be used to create such name tree in PDF document and add some embedded files to the name tree.
If an EmbeddedFiles name tree is specified, this function will construct the Attachments object from the name tree, along with the related PDF document.

Parameters
docA valid PDF document object.
nametreeA PDFNameTree object that represents an EmbeddedFiles name tree. If this PDFNameTree object is constructed by default constructor and has not been set any value, that means the Attachments object will be constructed from PDF document; otherwise, please ensure it belongs to the PDF document specified by parameter doc. Default value: a PDFNameTree object by default constructor and not set any value.

Member Function Documentation

◆ AddEmbeddedFile()

bool foxit.pdf.Attachments.AddEmbeddedFile ( string  key,
FileSpec  file_spec 
)
inline

Add an embedded attachment (as FileSpec object) with new key name.

All attachments in EmbeddedFiles name tree are ordered by their keys. When a new attachment is added, Foxit PDF SDK will find a suitable place in the name tree to add it. After adding successfully, the indexes of some old keys may be changed.

Parameters
keyNew key string. If this is an empty string, the name of input file_spec will be used as the new key. This new key should not have existed in the PDF document to which current Attachments object belongs.
file_specA FileSpec object to be added with new key. It should be valid and should has been embedded to the same PDF document as current Attachments object.
Returns
true means success, while false means failure.

◆ AddFromFilePath()

bool foxit.pdf.Attachments.AddFromFilePath ( string  key,
string  file_path 
)
inline

Add a new attachment from specified file path with new key name.

All attachments in EmbeddedFiles name tree are ordered by their keys. When a new attachment is added, Foxit PDF SDK will find a suitable place in the name tree to add it. After adding successfully, the indexes of some old keys may be changed.

Parameters
keyNew key string. If this is an empty string, the name of input file_spec will be used as the new key. This new key should not have existed in the PDF document to which current Attachments object belongs.
file_pathA file path to specify a file to be embedded to the PDF document and also added to EmbeddedFiles name tree.
Returns
true means success, while false means failure.

◆ ExtractEmbeddedFileTo()

bool foxit.pdf.Attachments.ExtractEmbeddedFileTo ( string  key,
string  dst_file_path 
)
inline

Extract an attachment and save it to a specified file path.

Parameters
keyKey string. This should not be an empty string.
dst_file_pathA file path, to which the data of attachment will be saved. This should not be an empty string.
Returns
true means success, while false means failure.

◆ GetCount()

int foxit.pdf.Attachments.GetCount ( )
inline

Get the count of attachments.

Returns
The count of attachments.

◆ GetEmbeddedFile()

FileSpec foxit.pdf.Attachments.GetEmbeddedFile ( string  key)
inline

Get the attachment (as FileSpec object) of a specified key.

Parameters
keyKey string. It should not be an empty string.
Returns
A FileSpec object.

◆ GetKey()

string foxit.pdf.Attachments.GetKey ( int  index)
inline

Get the key of an attachment defined in the EmbeddedFiles name tree, by index.

Parameters
indexIndex of the key string to be retrieved. Valid range: from 0 to (count-1). count is returned by function Attachments::GetCount.
Returns
A key string.

◆ GetNameTree()

PDFNameTree foxit.pdf.Attachments.GetNameTree ( )
inline

Get the EmbeddedFiles name tree.

Returns
The EmbeddedFiles name tree.

◆ IsEmpty()

bool foxit.pdf.Attachments.IsEmpty ( )
inline

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ RemoveAllEmbeddedFiles()

bool foxit.pdf.Attachments.RemoveAllEmbeddedFiles ( )
inline

Remove all attachments.

Returns
true means success, while false means failure.

◆ RemoveEmbeddedFile()

bool foxit.pdf.Attachments.RemoveEmbeddedFile ( string  key)
inline

Remove an attachment by key.

If the input key does not exist in EmbeddedFiles name tree, this function will return true directly.

Parameters
keyKey string. This should not be an empty string.
Returns
true means success, while false means failure.

◆ SetEmbeddedFile()

bool foxit.pdf.Attachments.SetEmbeddedFile ( string  key,
FileSpec  file_spec 
)
inline

Set an embedded attachment (as FileSpec object) for a specified key.

Parameters
keyKey string. It should not be an empty string. This name should have existed in current PDF document.
file_specA FileSpec object to be set to the key's value. It should be valid and should has been embedded to the same PDF document as current Attachments object.
Returns
true means success, while false means failure.

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.