Foxit PDF SDK
FSPDFObject Class Reference
Inheritance diagram for FSPDFObject:
FSPDFArray FSPDFDictionary FSPDFStream

Instance Methods

(FSPDFObject *) - cloneObject
 Clone current PDF object and get the cloned PDF object.
More...
 
(FSPDFObject *) - deepCloneObject
 Clone current PDF object and get the cloned PDF object.
More...
 
(void) - destroy
 Release a newly created PDF object or a clone PDF object, which is not related to PDF document or other PDF object and will not be used any more.
More...
 
(FSPDFArray *) - getArray
 Get the PDF array object of current PDF object.
More...
 
(BOOL) - getBoolean
 Get the boolean value of current PDF object.
More...
 
(FSDateTime *) - getDateTime
 Get the date time value of current PDF object.
More...
 
(FSPDFDictionary *) - getDict
 Get the PDF dictionary object of current PDF object.
More...
 
(FSPDFObject *) - getDirectObject
 Get the direct object of current PDF object.
More...
 
(float) - getFloat
 Get the float value of current PDF object.
More...
 
(int) - getInteger
 Get the integer value of current PDF object.
More...
 
(FSMatrix2D *) - getMatrix
 Get the matrix value of current PDF object.
More...
 
(NSString *) - getName
 Get the name value of current PDF object.
More...
 
(unsigned int) - getObjNum
 Get the indirect object number of current PDF object.
More...
 
(FSRectF *) - getRect
 Get the rectangle value of current PDF object.
More...
 
(FSPDFStream *) - getStream
 Get the PDF stream object of current PDF object.
More...
 
(NSData *) - getString
 Get the string value of current PDF object.
More...
 
(FSPDFObjectType- getType
 Get the type of current PDF object.
More...
 
(NSString *) - getWideString
 Get the wide string value of current PDF object.
More...
 
(BOOL) - isIdentical:
 Check if input PDF object is identical with current PDF object.
More...
 

Class Methods

(FSPDFObject *) + createFromBoolean:
 Create a PDF object from a boolean value.
More...
 
(FSPDFObject *) + createFromDateTime:
 Create a PDF object from date time.
More...
 
(FSPDFObject *) + createFromFloat:
 Create a PDF object from a float number.
More...
 
(FSPDFObject *) + createFromInteger:
 Create a PDF object from a integer number.
More...
 
(FSPDFObject *) + createFromName:
 Create a PDF object from a string which represents a name.
More...
 
(FSPDFObject *) + createFromString:
 Create a PDF object from string.
More...
 
(FSPDFObject *) + createReference:object_number:
 Create a reference for an indirect object.
More...
 

Detailed Description

PDF supports eight basic types of objects:
"Boolean value", "Integer and real number", "String", "Name", "Array", "Dictionary", "Stream", "The null object". For more details about PDF objects, please refer to Section 3.2 "Objects" in <PDF Reference 1.7>.
Class FSPDFObject is a base class for all kinds of PDF objects. It offers different functions to create different kind of PDF objects. For "Array", "Dictionary" and "Stream" PDF object, please refer to derived classes FSPDFArray, FSPDFDictionary and FSPDFStream .
If user wants to make a newly created PDF object to be an indirect object, please call function pdf::PDFDoc::addIndirectObject:.

See also
FSPDFArray
FSPDFDictionary
FSPDFStream
FSPDFDoc

Method Documentation

◆ cloneObject()

- (FSPDFObject *) cloneObject

Clone current PDF object and get the cloned PDF object.

Please call PDFObject::destroy to release the new object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Returns
A new FSPDFObject object as the clone result. If there is any error, this function will return nil.

◆ createFromBoolean:()

+ (FSPDFObject *) createFromBoolean: (BOOL)  boolean_value

Create a PDF object from a boolean value.

Please call function PDFObject::destroy to release the created object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Parameters
[in]boolean_valueA boolean value.
Returns
A new FSPDFObject object, whose object type is FSPDFObjectBoolean. If there is any error, this function will return nil.

◆ createFromDateTime:()

+ (FSPDFObject *) createFromDateTime: (FSDateTime*)  date_time

Create a PDF object from date time.

PDF defines a standard date format, which closely follows that of the international standard ASN.1 (Abstract Syntax Notation One), defined in ISO/ IEC 8824 (see the Bibliography). A date is defined as an ASCII string of the form (D:YYYYMMDDHHmmSSOHH'mm'). Please call function PDFObject::destroy to release the created object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Parameters
[in]date_timeA date and time object.
Returns
A new FSPDFObject object, whose object type is FSPDFObjectString. If there is any error, this function will return nil.

◆ createFromFloat:()

+ (FSPDFObject *) createFromFloat: (float)  float_value

Create a PDF object from a float number.

Please call function PDFObject::destroy to release the created object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Parameters
[in]float_valueA float value.
Returns
A new FSPDFObject object, whose object type is FSPDFObjectNumber. If there is any error, this function will return nil.

◆ createFromInteger:()

+ (FSPDFObject *) createFromInteger: (int)  integer_value

Create a PDF object from a integer number.

Please call function PDFObject::destroy to release the created object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Parameters
[in]integer_valueAn integer value.
Returns
A new FSPDFObject object, whose object type is FSPDFObjectNumber. If there is any error, this function will return nil.

◆ createFromName:()

+ (FSPDFObject *) createFromName: (NSString *)  name

Create a PDF object from a string which represents a name.

Please call function PDFObject::destroy to release the created object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Parameters
[in]nameA string. It should not be an empty string.
Returns
A new FSPDFObject object, whose object type is FSPDFObjectName. If there is any error, this function will return nil.

◆ createFromString:()

+ (FSPDFObject *) createFromString: (NSString *)  string_value

Create a PDF object from string.

Please call function PDFObject::destroy to release the created object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Parameters
[in]string_valueA string. It should not be an empty string.
Returns
A FSPDFObject object, whose object type is FSPDFObjectString. If there is any error, this function will return nil.

◆ createReference:object_number:()

+ (FSPDFObject *) createReference: (FSPDFDoc*)  document
object_number: (unsigned int)  object_number 

Create a reference for an indirect object.

The indirect object can be retrieved by following methods:

Please call function PDFObject::destroy to release the created object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Parameters
[in]documentA valid PDF document object.
[in]object_numberThe indirect object number of the indirect PDF object. This should be above 0.
Returns
A new FSPDFObject object, whose object type is FSPDFObjectReference. If there is any error, this function will return nil.

◆ deepCloneObject()

- (FSPDFObject *) deepCloneObject

Clone current PDF object and get the cloned PDF object.

This function is a totally direct copy, without any reference object inside, so the copy object can be copied to another document. Please call PDFObject::destroy to release the new object if it has not been added/set into PDF document or other PDF object and will not be used any more.

Returns
A new FSPDFObject object as the clone result. If there is any error, this function will return nil.

◆ destroy()

- (void) destroy

Release a newly created PDF object or a clone PDF object, which is not related to PDF document or other PDF object and will not be used any more.

This function should be called only for a newly created PDF object or a cloned PDF object, which has not been added or set to other PDF object or related to PDF document, and will not be used any more. Please do not use this function for other case, otherwise unknown error may occur.

Returns
None.

◆ getArray()

- (FSPDFArray *) getArray

Get the PDF array object of current PDF object.

If the type of current PDF object is FSPDFObjectReference, this function will check the direct PDF object of current PDF object.

Returns
A PDF array object. If current PDF object or the direct PDF object is not a PDF array, nil will be returned.

◆ getBoolean()

- (BOOL) getBoolean

Get the boolean value of current PDF object.

Only useful when the type of current PDF object is FSPDFObjectBoolean.

Returns
The boolean value. For PDF object in other type, NO will be returned.

◆ getDateTime()

- (FSDateTime *) getDateTime

Get the date time value of current PDF object.

Only useful when the type of current PDF objec is FSPDFObjectString and its content is in PDF standard date format.

Returns
The data time information. If there is any error or current object is in other type, an empty date and time object will be returned.

◆ getDict()

- (FSPDFDictionary *) getDict

Get the PDF dictionary object of current PDF object.

If the type of current PDF object is FSPDFObjectReference, this function will check the direct PDF object of current PDF object.

Returns
A PDF dictionary object. If current PDF object or the direct PDF object is not a PDF dictionary, nil will be returned.

◆ getDirectObject()

- (FSPDFObject *) getDirectObject

Get the direct object of current PDF object.

If the type of current PDF object is FSPDFObjectReference, the direct object will be returned.

Returns
The direct PDF object. For PDF object in other type, this function will return current PDF object itself. If there is any error, this function will return nil.

◆ getFloat()

- (float) getFloat

Get the float value of current PDF object.

Only useful when the type of current PDF object is FSPDFObjectNumber.

Returns
The float value. For PDF object in other type, 0.0f will be returned.

◆ getInteger()

- (int) getInteger

Get the integer value of current PDF object.

Only useful when the type of current PDF object is FSPDFObjectNumber.

Returns
The integer value. For PDF object in other type, 0 will be returned.

◆ getMatrix()

- (FSMatrix2D *) getMatrix

Get the matrix value of current PDF object.

Only useful for PDF object whose type is FSPDFObjectArray and it has 6 number objects as elements.

Returns
A matrix. If there is any error or current object is in other type, a matrix with value [0 0 0 0 0 0] will be returned.

◆ getName()

- (NSString *) getName

Get the name value of current PDF object.

Only useful when the type of current PDF object is FSPDFObjectName or FSPDFObjectString.

Returns
A string that represents the value. If there is any error or current object is in other type, an empty string will be returned.

◆ getObjNum()

- (unsigned int) getObjNum

Get the indirect object number of current PDF object.

Returns
The indirect object number. It would be:
  • 0 if current PDF object is a direct object.
  • above 0 if current PDF object is an indirect object.
  • -1 means there is any error.

◆ getRect()

- (FSRectF *) getRect

Get the rectangle value of current PDF object.

Only useful for PDF object whose type is FSPDFObjectArray and it has 4 number objects as elements.

Returns
A rectangle. If there is any error or current object is in other type, a rectangle with value [0 0 0 0] will be returned.

◆ getStream()

- (FSPDFStream *) getStream

Get the PDF stream object of current PDF object.

If the type of current PDF object is FSPDFObjectReference, this function will check the direct PDF object of current PDF object.

Returns
A PDF stream object. If current PDF object or the direct PDF object is not a PDF stream, nil will be returned.

◆ getString()

- (NSData *) getString

Get the string value of current PDF object.

This function will get the string format for actual value of current PDF object:

  • If object type is FSPDFObjectBoolean, "true" or "false" string value will be returned, depending on its actual value.
  • If object type is FSPDFObjectNumber, the value will be represents as a string. For example, "1.5" string is for value 1.5.
  • If object type is FSPDFObjectString, the string value will be retrieved directly.

If value of current PDF object cannot be converted to a valid string, an empty string will be returned.

Returns
A string.

◆ getType()

- (FSPDFObjectType) getType

Get the type of current PDF object.

Returns
PDF object type. Please refer to values starting from FSPDFObjectBoolean and this would be one of these values.

◆ getWideString()

- (NSString *) getWideString

Get the wide string value of current PDF object.

This function will get the string format for actual value of current PDF object:

  • If object type is FSPDFObjectBoolean, "true" or "false" string value will be returned, depending on its actual value.
  • If object type is FSPDFObjectNumber, the value will be represents as a string. For example, "1.5" string is for value 1.5.
  • If object type is FSPDFObjectString, the string value will be retrieved directly.

If value of current PDF object cannot be converted to a valid string, an empty string will be returned.

Returns
A string.

◆ isIdentical:()

- (BOOL) isIdentical: (FSPDFObject*)  pdf_obj

Check if input PDF object is identical with current PDF object.

Parameters
[in]pdf_objAnother PDF object which is to be check with current PDF object.
Returns
YES means input PDF object is identical with current PDF object, while NO means input PDF object is not identical with current PDF object.