Foxit PDF SDK
FSMetadata Class Reference
Inheritance diagram for FSMetadata:
FSBase

Instance Methods

(NSArray< NSString * > *) - getCustomerKeys
 Get customer keys from metadata.
More...
 
(NSArray< NSString * > *) - getValues:
 Get metadata value(s).
More...
 
(BOOL) - hasKey:
 Check whether the related PDF document has a specified metadata key or not.
More...
 
(id) - initWithDocument:
 Constructor, from a PDF document object.
More...
 
(id) - initWithOther:
 Constructor, with another metadata object.
More...
 
(BOOL) - isEmpty
 Check whether current object is empty or not.
More...
 
(void) - removeCustomerKey:
 Remove a specified customer key (along with related value).
More...
 
(BOOL) - setValues:value_array:
 Set metadata value(s).
More...
 

Properties

FSDateTimecreationDateTime
 Get or Set creation date time.

 
FSDateTimemodifiedDateTime
 Get or Set modified date time.

 

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.

Method Documentation

◆ getCustomerKeys()

- (NSArray< NSString * > *) getCustomerKeys

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.

◆ getValues:()

- (NSArray< NSString * > *) getValues: (NSString *)  key

Get metadata value(s).

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

Parameters
[in]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", "InstanceID", "DocumentID".
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::creationDateTime and Metadata::modifiedDateTime to get the date information.
Returns
An string array of metadata value(s).

◆ hasKey:()

- (BOOL) hasKey: (NSString *)  key

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

Parameters
[in]keyThe metadata key to be checked.
Returns
YES means the related PDF document has the specified metadata key, while NO means the related PDF document does not have the specified metadata key.

◆ initWithDocument:()

- (id) initWithDocument: (FSPDFDoc*)  document

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
[in]documentA valid PDF document object.

◆ initWithOther:()

- (id) initWithOther: (FSMetadata*)  other

Constructor, with another metadata object.

Parameters
[in]otherAnother metadata object.

◆ isEmpty()

- (BOOL) isEmpty

Check whether current object is empty or not.

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

Returns
YES means current object is empty, while NO means not.

◆ removeCustomerKey:()

- (void) removeCustomerKey: (NSString *)  key

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

Parameters
[in]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.

◆ setValues:value_array:()

- (BOOL) setValues: (NSString *)  key
value_array: (NSArray<NSString *> *)  value_array 

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
[in]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", "InstanceID", "DocumentID".
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 FSMetadata::creationDateTime and FSMetadata::modifiedDateTime to set the date information.
[in]value_arrayAn string array of metadata value(s).
Returns
None.