com.foxit.sdk.pdf.Metadata Class Reference
Inheritance diagram for com.foxit.sdk.pdf.Metadata:
com.foxit.sdk.common.Base

Public Member Functions

 Metadata (PDFDoc document) throws com.foxit.sdk.PDFException
 Constructor, from a PDF document object. More...
 
 Metadata (Metadata other)
 Constructor, with another Metadata object. More...
 
DateTime getCreationDateTime () throws com.foxit.sdk.PDFException
 Get creation date time. More...
 
WStringArray getCustomerKeys () throws com.foxit.sdk.PDFException
 Get customer keys from metadata. More...
 
DateTime getModifiedDateTime () throws com.foxit.sdk.PDFException
 Get modified date time. More...
 
WStringArray getValues (String key) throws com.foxit.sdk.PDFException
 Get metadata value(s). More...
 
boolean hasKey (String key) throws com.foxit.sdk.PDFException
 Check whether the related PDF document has a specified metadata key or not. More...
 
boolean isEmpty ()
 Check whether current object is empty or not. More...
 
void removeCustomerKey (String key) throws com.foxit.sdk.PDFException
 Remove a specified customer key (along with related value). More...
 
void setCreationDateTime (DateTime date_time) throws com.foxit.sdk.PDFException
 Set creation date time. More...
 
void setModifiedDateTime (DateTime date_time) throws com.foxit.sdk.PDFException
 Set modified date time. More...
 
boolean setValues (String key, WStringArray value_array) throws com.foxit.sdk.PDFException
 Set metadata value(s). More...
 

Detailed Description

In PDF document, metadata information is stored in document's Info dictionary or in metadata stream (represented in Extensible Markup Language, known as XML). When a key exists in both Info dictionary and metadata stream, the latest modified one will be used.
This class is constructed from PDF document object and is used to get or set metadata information from both document's Info dictionary and metadata stream.

Constructor & Destructor Documentation

◆ Metadata() [1/2]

com.foxit.sdk.pdf.Metadata.Metadata ( PDFDoc  document) throws com.foxit.sdk.PDFException

Constructor, from a PDF document object.

If there exists metadata information in the specified PDF document, this function is just to construct a Metadata object to be associated with these information. If there is no such information in the specified PDF document, the constructed Metadata object can be used to set metadata information to PDF document.

Parameters
documentA valid PDF document object.

◆ Metadata() [2/2]

com.foxit.sdk.pdf.Metadata.Metadata ( Metadata  other)

Constructor, with another Metadata object.

Parameters
otherAnother Metadata object.

Member Function Documentation

◆ getCreationDateTime()

DateTime com.foxit.sdk.pdf.Metadata.getCreationDateTime ( ) throws com.foxit.sdk.PDFException

Get creation date time.

Returns
Creation date time. If no creation date time can be found, a DateTime with all values 0 will be returned.

◆ getCustomerKeys()

WStringArray com.foxit.sdk.pdf.Metadata.getCustomerKeys ( ) throws com.foxit.sdk.PDFException

Get customer keys from metadata.

In Info dictionary and metadata stream, they have some standard keys which have same feature but different name. For this case, Foxit PDF SDK will use the standard key names in Info dictionary. Besides these standard keys, other keys will be treated as customer keys.

Returns
An string array of customer keys.

◆ getModifiedDateTime()

DateTime com.foxit.sdk.pdf.Metadata.getModifiedDateTime ( ) throws com.foxit.sdk.PDFException

Get modified date time.

Returns
Modified date time. If no modified date time can be found, a DateTime with all values 0 will be returned.

◆ getValues()

WStringArray com.foxit.sdk.pdf.Metadata.getValues ( String  key) throws com.foxit.sdk.PDFException

Get metadata value(s).

For a metadata key, it may contain single or multiple values.

Parameters
keyMetadata key string. It should not be an empty string. Currently it can be one of the following keys:
"Title", "Author", "Subject", "Keywords", "Creator", "Producer", "Trapped", "CreationDate", "ModDate", "pdfaid".
It can also be some other custom information keys if they're supported by the PDF file.
For "CreationDate" and "ModDate", user is recommended to use functions Metadata::getCreationDateTime and Metadata::getModifiedDateTime to get the date information.
Returns
An string array of metadata value(s).

◆ hasKey()

boolean com.foxit.sdk.pdf.Metadata.hasKey ( String  key) throws com.foxit.sdk.PDFException

Check whether the related PDF document has a specified metadata key or not.

Parameters
keyThe metadata key to be checked.
Returns
true means the related PDF document has the specified metadata key, while false means the related PDF document does not have the specified metadata key.

◆ isEmpty()

boolean com.foxit.sdk.pdf.Metadata.isEmpty ( )

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.

◆ removeCustomerKey()

void com.foxit.sdk.pdf.Metadata.removeCustomerKey ( String  key) throws com.foxit.sdk.PDFException

Remove a specified customer key (along with related value).

Parameters
keyA customer key string. It should not be an empty string. This should be one of the keys retrieved from function Metadata::getCustomerKeys.
Returns
None.

◆ setCreationDateTime()

void com.foxit.sdk.pdf.Metadata.setCreationDateTime ( DateTime  date_time) throws com.foxit.sdk.PDFException

Set creation date time.

Parameters
date_timeNew creation date time. Please refer to comment of class DateTime to check the valid range for each member.
Returns
None.

◆ setModifiedDateTime()

void com.foxit.sdk.pdf.Metadata.setModifiedDateTime ( DateTime  date_time) throws com.foxit.sdk.PDFException

Set modified date time.

Parameters
date_timeNew modified date time. Please refer to comment of class DateTime to check the valid range for each member.
Returns
None.

◆ setValues()

boolean com.foxit.sdk.pdf.Metadata.setValues ( String  key,
WStringArray  value_array 
) throws com.foxit.sdk.PDFException

Set metadata value(s).

This function is used to set single or multiple values to a specified metadata key:


For metadata keys "Author" and "Keywords", they can contain single or multiple values.
For metadata key "pdfaid" which means the PDFA file version, the length of its value string is always 2, such as "2a", "1a", etc. So, only the first two characters of the first element in parameter valueArray will be used.
For rest pre-defined keys, they do not support multiple values. So all the elements in parameter value_array will be put into one string and connected by ";". Then this string will be treated as a single value.

Parameters
keyMetadata key string. It should not be an empty string. Currently it can be one of the following keys:
"Title", "Author", "Subject", "Keywords", "Creator", "Producer", "Trapped", "CreationDate", "ModDate", "pdfaid".
It can also be some other custom information keys if they're supported by the PDF file.
For "CreationDate" and "ModDate", user is recommended to use functions Metadata::setCreationDateTime and Metadata::setModifiedDateTime to set the date information.
value_arrayAn string array of metadata value(s).
Returns
None.

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