Loading...
Searching...
No Matches
pdftron::SDF::Obj Class Reference

`#include <Obj.h>`

## Public Types
enum | Type { e_null , e_bool , e_number , e_name , e_string , e_dict , e_array , e_stream }

## Public Member Functions
Type | GetType () const
bool | IsBool () const
bool | IsNumber () const
bool | IsNull () const
bool | IsString () const
bool | IsName () const
bool | IsIndirect () const
bool | IsContainer () const
bool | IsDict () const
bool | IsArray () const
bool | IsStream () const
class SDFDoc & | GetDoc () const
void | Write (Filters::FilterWriter &stream)
size_t | Size () const
UInt32 | GetObjNum () const
UInt16 | GetGenNum () const
size_t | GetOffset () const
bool | IsFree () const
void | SetMark (bool mark)
bool | IsMarked () const
bool | IsLoaded () const
bool | IsValid () const
bool | GetBool () const
void | SetBool (bool b)
double | GetNumber () const
void | SetNumber (double n)
const UChar * | GetBuffer () const
std::vector< unsigned char > | GetRawBuffer () const
UString | GetAsPDFText () const
void | GetAsPDFText (UString &out_str) const
void | SetString (const UChar *value, size_t size)
void | SetString (const UString &str)
const char * | GetName () const
void | SetName (const char *name)
DictIterator | GetDictIterator ()
DictIterator | Find (const char *key)
Obj | FindObj (const char *key)
DictIterator | Get (const char *key)
Obj | PutName (const char *key, const char *name)
Obj | PutArray (const char *key)
Obj | PutBool (const char *key, bool value)
Obj | PutDict (const char *key)
Obj | PutNumber (const char *key, double value)
Obj | PutString (const char *key, const char *value)
Obj | PutString (const char *key, const char *value, int size)
Obj | PutText (const char *key, const UString &value)
void | PutNull (const char *key)
Obj | Put (const char *key, Obj obj)
Obj | PutRect (const char *key, double x1, double y1, double x2, double y2)
Obj | PutMatrix (const char *key, const Common::Matrix2D &value)
void | Erase (const char *key)
void | Erase (DictIterator pos)
bool | Rename (const char *old_key, const char *new_key)
Obj | GetAt (size_t index) const
Obj | InsertName (size_t pos, const char *name)
Obj | InsertArray (size_t pos)
Obj | InsertBool (size_t pos, bool value)
Obj | InsertDict (size_t pos)
Obj | InsertNumber (size_t pos, double value)
Obj | InsertString (size_t pos, const char *value)
Obj | InsertString (size_t pos, const char *value, int size)
Obj | InsertText (size_t pos, const UString &value)
Obj | InsertNull (size_t pos)
Obj | Insert (size_t pos, Obj obj)
Obj | InsertRect (size_t pos, double x1, double y1, double x2, double y2)
Obj | InsertMatrix (size_t pos, const Common::Matrix2D &value)
Obj | PushBackName (const char *name)
Obj | PushBackArray ()
Obj | PushBackBool (bool value)
Obj | PushBackDict ()
Obj | PushBackNumber (double value)
Obj | PushBackString (const char *value)
Obj | PushBackString (const char *value, int size)
Obj | PushBackText (const UString &value)
Obj | PushBackNull ()
Obj | PushBack (Obj obj)
Obj | PushBackRect (double x1, double y1, double x2, double y2)
Obj | PushBackMatrix (const Common::Matrix2D &value)
void | EraseAt (size_t pos)
size_t | GetRawStreamLength () const
Filters::Filter | GetRawStream (bool decrypt) const
Filters::Filter | GetDecodedStream () const
void | SetStreamData (const char *data, const size_t data_size, Filters::Filter filter_chain=Filters::Filter())
void | SetStreamData (const std::vector< unsigned char > &data, Filters::Filter filter_chain=Filters::Filter())
| Obj ()
| Obj (const Obj &c)
Obj & | operator= (const Obj &c)
| operator bool ()
bool | IsEqual (const Obj &to) const
bool | operator== (const Obj &to) const
bool | operator< (const Obj &to) const
ptrdiff_t | GetHandleInternal ()

## Static Public Member Functions
static Obj * | CreateInternal (ptrdiff_t impl)

## Detailed Description

Obj is a concrete class for all SDF/Cos objects. Obj hierarchy implements the composite design pattern. As a result, you can invoke a member function of any 'derived' object through Obj interface. If the member function is not supported (e.g. if you invoke Obj::GetNumber() on a boolean object) an Exception will be thrown.

You can use GetType() or obl.Is???() member functions to find out type-information at run time, however most of the time the type can be inferred from the PDF specification. Therefore when you call Doc::GetTrailer() you can assume that returned object is a dictionary. If there is any ambiguity use Is???() methods.

Objects can't be shared across documents, however you can use Doc::ImportObj() to copy objects from one document to another.

Objects can be shared within a document provided that they are created as indirect. Indirect objects are the ones that are referenced in cross-reference table. To create an object as indirect use doc.CreateIndirect???() (where ? is the Object type).

Definition at line 40 of file Obj.h.

## Member Enumeration Documentation

## ◆ Type

enum pdftron::SDF::Obj::Type

The object type.

Enumerator
e_null |
e_bool |
e_number |
e_name |
e_string |
e_dict |
e_array |
e_stream |

Definition at line 49 of file Obj.h.

## Constructor & Destructor Documentation

## ◆ Obj() [1/2]

pdftron::SDF::Obj::Obj | ( |  | ) |
| inline

Definition at line 892 of file Obj.h.

## ◆ Obj() [2/2]

pdftron::SDF::Obj::Obj | ( | const Obj & | c | ) |
| inline

Definition at line 893 of file Obj.h.

## Member Function Documentation

## ◆ CreateInternal()

Obj * pdftron::SDF::Obj::CreateInternal | ( | ptrdiff_t | impl | ) |
| static

## ◆ Erase() [1/2]

void pdftron::SDF::Obj::Erase | ( | const char * | key | ) |

Removes an element in the dictionary that matches the given key.

Parameters

  key | A string representing the key value of the element to remove.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream.

## ◆ Erase() [2/2]

void pdftron::SDF::Obj::Erase | ( | DictIterator | pos | ) |

Removes an element in the dictionary from specified position.

Parameters

  pos | A dictionary iterator indicating the position of the element to remove.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream.

## ◆ EraseAt()

void pdftron::SDF::Obj::EraseAt | ( | size_t | pos | ) |

Checks whether the position is within the array bounds and then removes it from the array and moves each subsequent element to the slot with the next smaller index and decrements the arrays length by 1.

Parameters

  pos | The index for the array member to remove. Array indexes start at 0.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ Find()

DictIterator pdftron::SDF::Obj::Find | ( | const char * | key | ) |

Search the dictionary for a given key.

Parameters

  key | - a key to search for in the dictionary

Returns
  The iterator to the matching key/value pair or invalid iterator (i.e. itr.HasCurrent()==fase) if the if the dictionary does not contain the given key.

Note
  A dictionary entry whose value is Obj::Null is equivalent to an absent entry.

Exceptions

  Exception | is thrown if this is not a dictionary or a stream

Sample code used to search a dictionary for a given key:

DictIterator itr = info_dict.Find("Info");
if (itr.HasCurrent()) {
Obj info = itr.Value();
if (info.IsDict())
info.PutString("Producer", "PDFTron PDFNet SDK");
}
pdftron::SDF::DictIterator
Definition DictIterator.h:33
pdftron::SDF::DictIterator::HasCurrent
bool HasCurrent()
pdftron::SDF::DictIterator::Value
SDF::Obj Value()
pdftron::SDF::Obj::Obj
Obj()
Definition Obj.h:892
pdftron::SDF::Obj::IsDict
bool IsDict() const
pdftron::SDF::Obj::PutString
Obj PutString(const char *key, const char *value)

## ◆ FindObj()

Obj pdftron::SDF::Obj::FindObj | ( | const char * | key | ) |

Search the dictionary for a given key.

Parameters

  key | - a key to search for in the dictionary

Returns
  NULL if the dictionary does not contain the specified key. Otherwise return the corresponding value.

Note
  A dictionary entry whose value is Obj::Null is equivalent to an absent entry.

Exceptions

  Exception | is thrown if this is not a dictionary or a stream

## ◆ Get()

DictIterator pdftron::SDF::Obj::Get | ( | const char * | key | ) |

Search the dictionary for a given key and throw an exception if the key is not found.

Parameters

  key | - a key to search for in the dictionary

Returns
  Obj::Null object if the value matching specified key is a Obj::Null object. otherwise return the iterator to the matching key/value pair.

Exceptions

  An | Exception is thrown if the dictionary does not contain the specified key.
  An | Exception is thrown if this is not a Obj::Type::e_dict or a stream.

## ◆ GetAsPDFText() [1/2]

UString pdftron::SDF::Obj::GetAsPDFText | ( |  | ) | const

Convert the SDF/Cos String object to 'PDF Text String' (a Unicode string).

PDF Text Strings are not used to represent page content, however they are used in text annotations, bookmark names, article names, document information etc. These strings are encoded in either PDFDocEncoding or Unicode character encoding. For more information on PDF Text Strings, please refer to section 3.8.1 'Text Strings' in PDF Reference.

Note
  Not all SDF/Cos String objects are used to represent 'PDF Text'. PDF Reference indicates (on a case by case basis ) where an SDF/Cos String object can be used as 'PDF Text'.

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_string.

## ◆ GetAsPDFText() [2/2]

void pdftron::SDF::Obj::GetAsPDFText | ( | UString & | out_str | ) | const

## ◆ GetAt()

Obj pdftron::SDF::Obj::GetAt | ( | size_t | index | ) | const

Parameters

  index | - The array element to obtain. The first element in an array has an index of zero.

Exceptions

  throws | an Exception if index is outside the array bounds.
  An | Exception is thrown if this is not an Obj::Type::e_array.

## ◆ GetBool()

bool pdftron::SDF::Obj::GetBool | ( |  | ) | const

Returns
  bool value if this is Bool.

Exceptions

  Exception | is thrown if the object is not Obj::Type::e_bool

## ◆ GetBuffer()

const UChar * pdftron::SDF::Obj::GetBuffer | ( |  | ) | const

Returns
  a pointer to the string buffer. Please note that the string may not be NULL terminated and that it may not be represented in ASCII or Unicode encoding. For more information on SDF/Cos String objects, please refer to section 3.2.3 'String Objects' in PDF Reference Manual.

Note
  if SDF/Cos String object is represented as 'PDF Text' (Section 3.8.1 'Text Strings' in PDF Reference) you can use GetAsPDFText method to obtain Unicode representation of the string.
  use Size() member function in order to obtain the number of bytes in string buffer.

Exceptions

  Exception | is thrown if this is not a Obj::Type::e_string.

## ◆ GetDecodedStream()

Filters::Filter pdftron::SDF::Obj::GetDecodedStream | ( |  | ) | const

Returns
  - A filter to the decoded stream

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_stream

## ◆ GetDictIterator()

DictIterator pdftron::SDF::Obj::GetDictIterator | ( |  | ) |

Returns
  an iterator that addresses the first element in the dictionary.

Exceptions

  An | Exception is thrown if this is not a dictionary object (Dict).

Sample code used to traverse all entries in the dictionary:

DictIterator itr = dict.GetDictIterator();
while (itr.HasCurrent()) {
Obj key = itr.Key();
Obj value = itr.Value();
// ...
itr.Next()
}
pdftron::SDF::DictIterator::Key
SDF::Obj Key()
pdftron::SDF::DictIterator::Next
void Next()

## ◆ GetDoc()

class SDFDoc & pdftron::SDF::Obj::GetDoc | ( |  | ) | const

Returns
  the document to which this object belongs.

Note
  this method can be invoked on any Obj.

## ◆ GetGenNum()

UInt16 pdftron::SDF::Obj::GetGenNum | ( |  | ) | const

Returns
  generation number. If this is not an Indirect object, generation number of a containing indirect object is returned.

Note
  this method can be invoked on any Obj.

## ◆ GetHandleInternal()

ptrdiff_t pdftron::SDF::Obj::GetHandleInternal | ( |  | ) |

## ◆ GetName()

const char * pdftron::SDF::Obj::GetName | ( |  | ) | const

Returns
  string representing the Name object.

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_name

## ◆ GetNumber()

double pdftron::SDF::Obj::GetNumber | ( |  | ) | const

Returns
  value, if this is Number.

Exceptions

  An | Exception is thrown if the object is not a Obj::Type::e_number

## ◆ GetObjNum()

UInt32 pdftron::SDF::Obj::GetObjNum | ( |  | ) | const

Returns
  object number. If this is not an Indirect object, object number of a containing indirect object is returned.

Note
  this method can be invoked on any Obj.

## ◆ GetOffset()

size_t pdftron::SDF::Obj::GetOffset | ( |  | ) | const

Returns
  object offset from the beginning of the file. If this is not an Indirect object, offset of a containing indirect object is returned.

Note
  this method can be invoked on any Obj.

## ◆ GetRawBuffer()

std::vector< unsigned char > pdftron::SDF::Obj::GetRawBuffer | ( |  | ) | const

Returns
  a vector containing the encrypted string buffer.

Note
  Similar in behaviour to GetBuffer except that no decryption is done. If the file is not encrypted the result should be the same as GetBuffer

Exceptions

  Exception | is thrown if this is not a Obj::Type::e_string.

## ◆ GetRawStream()

Filters::Filter pdftron::SDF::Obj::GetRawStream | ( | bool | decrypt | ) | const

Parameters

  decrypt | - If true decrypt the stream if the stream is encrypted.

Returns
  - A filter to the encoded stream

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_stream

## ◆ GetRawStreamLength()

size_t pdftron::SDF::Obj::GetRawStreamLength | ( |  | ) | const

Returns
  the length of the raw/encoded stream equal to the Length parameter

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_stream

## ◆ GetType()

Type pdftron::SDF::Obj::GetType | ( |  | ) | const

Returns
  the object type.

Note
  this method can be invoked on any Obj.

## ◆ Insert()

Obj pdftron::SDF::Obj::Insert | ( | size_t | pos,
|  | Obj | obj )

Inserts an existing Obj in this array.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  obj | The value to be inserted into the dictionary. If 'obj' is indirect (i.e. is a shared) object it will be inserted by reference, otherwise the object will be cloned and then inserted.

Returns
  A newly inserted object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertArray()

Obj pdftron::SDF::Obj::InsertArray | ( | size_t | pos | ) |

Inserts an Obj::Type::e_array object in the array.

Returns
  A newly created array object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertBool()

Obj pdftron::SDF::Obj::InsertBool | ( | size_t | pos,
|  | bool | value )

Inserts an Obj::Type::e_bool object in the array.

Returns
  A newly created boolean object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  value | The value of the Obj::Type::e_bool object to be inserted.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertDict()

Obj pdftron::SDF::Obj::InsertDict | ( | size_t | pos | ) |

Inserts an Obj::Type::e_dict object in the array.

Returns
  A newly created dictionary object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertMatrix()

Obj pdftron::SDF::Obj::InsertMatrix | ( | size_t | pos,
|  | const Common::Matrix2D & | value )

Inserts an array of 6 numbers in this array.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  value | - A matrix used to set the values in an array of six numbers. The resulting array will be then inserted in this array.

Returns
  A newly created array object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertName()

Obj pdftron::SDF::Obj::InsertName | ( | size_t | pos,
|  | const char * | name )

Inserts an Obj::Type::e_name object in the array.

Returns
  A newly created name object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  name | The value of the Obj::Type::e_name object to be inserted.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertNull()

Obj pdftron::SDF::Obj::InsertNull | ( | size_t | pos | ) |

Inserts an Obj::Type::e_null object in the array.

Returns
  A newly created null object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertNumber()

Obj pdftron::SDF::Obj::InsertNumber | ( | size_t | pos,
|  | double | value )

Inserts an Obj::Type::e_number object in the array.

Returns
  A newly created number object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  value | The value of the Obj::Type::e_number object to be inserted.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertRect()

Obj pdftron::SDF::Obj::InsertRect | ( | size_t | pos,
|  | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2 )

Inserts an array of 4 numbers in this array.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  x1 | The bottom left x value of the rect to be inserted
  y1 | The bottom left y value of the rect to be inserted
  x2 | The top right x value of the rect to be inserted
  y2 | The top right y value of the rect to be inserted

Returns
  A newly created array object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertString() [1/2]

Obj pdftron::SDF::Obj::InsertString | ( | size_t | pos,
|  | const char * | value )

Inserts an Obj::Type::e_string object in the array.

Returns
  A newly created string object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  value | The value of the Obj::Type::e_string object to be inserted.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertString() [2/2]

Obj pdftron::SDF::Obj::InsertString | ( | size_t | pos,
|  | const char * | value,
|  | int | size )

Inserts an Obj::Type::e_string object in the array.

Returns
  A newly created string object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  value | The buffer used to set the value of the Obj::Type::e_string object to be inserted.
  size | The number of bytes to copy from the 'value' buffer parameter.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ InsertText()

Obj pdftron::SDF::Obj::InsertText | ( | size_t | pos,
|  | const UString & | value )

Inserts an Obj::Type::e_string object in the array.

Returns
  A newly created string object.

Parameters

  pos | - The location in the array to insert the object . The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= Array->Length(), appends obj to array.
  value | The value of the Obj::Type::e_string object to be inserted.

Note
  InsertText will create the string object as a 'PDF Text' object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ IsArray()

bool pdftron::SDF::Obj::IsArray | ( |  | ) | const

Returns
  true if this is an Array, false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsBool()

bool pdftron::SDF::Obj::IsBool | ( |  | ) | const

Returns
  true if this is a Bool object, false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsContainer()

bool pdftron::SDF::Obj::IsContainer | ( |  | ) | const

Returns
  true if this is a Container (a dictionary, array, or a stream), false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsDict()

bool pdftron::SDF::Obj::IsDict | ( |  | ) | const

Returns
  true if this is a dictionary (i.e. Dict), false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsEqual()

bool pdftron::SDF::Obj::IsEqual | ( | const Obj & | to | ) | const

Returns
  true if two Obj's point to the same object. This method does not compare object content. For this operation use IsEqualValue() instead.

Parameters

  to | - Obj to compare to

## ◆ IsFree()

bool pdftron::SDF::Obj::IsFree | ( |  | ) | const

Returns
  true if the object is in use or is marked as free.

Note
  this method can be invoked on any Obj.

## ◆ IsIndirect()

bool pdftron::SDF::Obj::IsIndirect | ( |  | ) | const

Returns
  true if this is Indirect object (i.e. object referenced in the cross-reference table), false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsLoaded()

bool pdftron::SDF::Obj::IsLoaded | ( |  | ) | const

Returns
  true if the object is loaded in memory.

Note
  this method can be invoked on any Obj.

## ◆ IsMarked()

bool pdftron::SDF::Obj::IsMarked | ( |  | ) | const

Returns
  true if the object is marked.

Note
  this method can be invoked on any Obj.

## ◆ IsName()

bool pdftron::SDF::Obj::IsName | ( |  | ) | const

Returns
  true if this is Name, false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsNull()

bool pdftron::SDF::Obj::IsNull | ( |  | ) | const

Returns
  true if this is a Null object, false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsNumber()

bool pdftron::SDF::Obj::IsNumber | ( |  | ) | const

Returns
  true if this is a Number object, false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsStream()

bool pdftron::SDF::Obj::IsStream | ( |  | ) | const

Returns
  true if this is a Stream, false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsString()

bool pdftron::SDF::Obj::IsString | ( |  | ) | const

Returns
  true if this is a Str (String) object, false otherwise.

Note
  this method can be invoked on any Obj.

## ◆ IsValid()

bool pdftron::SDF::Obj::IsValid | ( |  | ) | const

Returns
  true if this is a valid object, false otherwise. If the function returns false then the underlying SDF/Cos object is null or is not valid.

## ◆ operator bool()

pdftron::SDF::Obj::operator bool | ( |  | ) |
| inline

Returns
  true if the object is not null, false otherwise.

Definition at line 899 of file Obj.h.

## ◆ operator<()

bool pdftron::SDF::Obj::operator< | ( | const Obj & | to | ) | const
| inline

Definition at line 909 of file Obj.h.

## ◆ operator=()

Obj & pdftron::SDF::Obj::operator= | ( | const Obj & | c | ) |
| inline

Definition at line 894 of file Obj.h.

## ◆ operator==()

bool pdftron::SDF::Obj::operator== | ( | const Obj & | to | ) | const

## ◆ PushBack()

Obj pdftron::SDF::Obj::PushBack | ( | Obj | obj | ) |

Appends an existing Obj at the end of the array.

Parameters

  obj | The value to be inserted into the dictionary. If 'obj' is indirect (i.e. is a shared) object it will be inserted by reference, otherwise the object will be cloned and then appended.

Returns
  A newly appended object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackArray()

Obj pdftron::SDF::Obj::PushBackArray | ( |  | ) |

Appends a new Obj::Type::e_array object at the end of the array.

Returns
  The new array object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackBool()

Obj pdftron::SDF::Obj::PushBackBool | ( | bool | value | ) |

Appends a new Obj::Type::e_bool object at the end of the array.

Returns
  The new boolean object.

Parameters

  value | - The value of the Obj::Type::e_bool object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackDict()

Obj pdftron::SDF::Obj::PushBackDict | ( |  | ) |

Appends a new Obj::Type::e_dict object at the end of the array.

Returns
  The new dictionary object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackMatrix()

Obj pdftron::SDF::Obj::PushBackMatrix | ( | const Common::Matrix2D & | value | ) |

Appends an array of 6 numbers at the end of the array.

Parameters

  value | - A matrix used to set the values in an array of six numbers. The resulting array will be then inserted in this array.

Returns
  A newly appended array object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackName()

Obj pdftron::SDF::Obj::PushBackName | ( | const char * | name | ) |

Appends a new Obj::Type::e_name object at the end of the array.

Returns
  The new array object.

Parameters

  name | - The value of the Obj::Type::e_name object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackNull()

Obj pdftron::SDF::Obj::PushBackNull | ( |  | ) |

Appends a new Obj::Type::e_null object at the end of the array.

Returns
  The new null object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackNumber()

Obj pdftron::SDF::Obj::PushBackNumber | ( | double | value | ) |

Appends a new Obj::Type::e_number object at the end of the array.

Returns
  The new number object.

Parameters

  value | - The value of the Obj::Type::e_number object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackRect()

Obj pdftron::SDF::Obj::PushBackRect | ( | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2 )

Appends an array of 4 numbers at the end of the array.

Parameters

  x1 | The bottom left x value of the rect to be inserted
  y1 | The bottom left y value of the rect to be inserted
  x2 | The top right x value of the rect to be inserted
  y2 | The top right y value of the rect to be inserted

Returns
  A newly appended array object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackString() [1/2]

Obj pdftron::SDF::Obj::PushBackString | ( | const char * | value | ) |

Appends a new Obj::Type::e_string object at the end of the array.

Returns
  The new string object.

Parameters

  value | - The value of the Obj::Type::e_string object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackString() [2/2]

Obj pdftron::SDF::Obj::PushBackString | ( | const char * | value,
|  | int | size )

Appends a new Obj::Type::e_string object at the end of the array.

Returns
  The new string object.

Parameters

  value | The buffer used to set the value of the Obj::Type::e_string object to be inserted.
  size | The number of bytes to copy from the 'value' buffer parameter.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ PushBackText()

Obj pdftron::SDF::Obj::PushBackText | ( | const UString & | value | ) |

Appends a new Obj::Type::e_string object at the end of the array.

Returns
  The new string object.

Parameters

  value | The value of the Obj::Type::e_string object to be inserted.

Note
  InsertText will create the string object as a 'PDF Text' object.

Exceptions

  An | Exception is thrown if this is not an Obj::Type::e_array

## ◆ Put()

Obj pdftron::SDF::Obj::Put | ( | const char * | key,
|  | Obj | obj )

Inserts a <key, Obj> pair in the dictionary.

Parameters

  key | The key of the value to set.
  obj | The value to be inserted into the dictionary. If 'obj' is indirect (i.e. is a shared) object it will be inserted by reference, otherwise the object will be cloned and then inserted into the dictionary.

Returns
  A newly inserted object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

## ◆ PutArray()

Obj pdftron::SDF::Obj::PutArray | ( | const char * | key | ) |

Inserts a <key, Obj::Type::e_array> pair in the dictionary.

Parameters

  key | The key of the value to set.

Returns
  A newly created array object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutBool()

Obj pdftron::SDF::Obj::PutBool | ( | const char * | key,
|  | bool | value )

Inserts a <key, Obj::Type::e_bool> pair in the dictionary.

Parameters

  key | The key of the value to set.
  value | The value of the Obj::Type::e_bool object to be inserted into the dictionary.

Returns
  A newly created boolean object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutDict()

Obj pdftron::SDF::Obj::PutDict | ( | const char * | key | ) |

Inserts a <key, Obj::Type::e_dict> pair in the dictionary.

Parameters

  key | The key of the value to set.

Returns
  A newly created dictionary.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutMatrix()

Obj pdftron::SDF::Obj::PutMatrix | ( | const char * | key,
|  | const Common::Matrix2D & | value )

Inserts a <key, [a,b,c,d,h,v]> pair in the dictionary.

Parameters

  key | The key of the value to set.
  value | - A matrix used to set the values in an array of six numbers. The resulting array will be inserted into the dictionary.

Returns
  A newly created array object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutName()

Obj pdftron::SDF::Obj::PutName | ( | const char * | key,
|  | const char * | name )

Inserts a <key, Obj::Type::e_name> pair in the dictionary.

Parameters

  key | The key of the value to set.
  name | The value of the Obj::Type::e_name object to be inserted into the dictionary.

Returns
  A newly created name object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutNull()

void pdftron::SDF::Obj::PutNull | ( | const char * | key | ) |

Inserts a <key, Obj::Type::e_null> pair in the dictionary.

Parameters

  key | The key of the value to set.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  The effect of calling this method is essentially the same as dict.Erase(key) .

## ◆ PutNumber()

Obj pdftron::SDF::Obj::PutNumber | ( | const char * | key,
|  | double | value )

Inserts a <key, Obj::Type::e_number> pair in the dictionary.

Parameters

  key | The key of the value to set.
  value | The value of the Obj::Type::e_number object to be inserted into the dictionary.

Returns
  A newly created number object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutRect()

Obj pdftron::SDF::Obj::PutRect | ( | const char * | key,
|  | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2 )

Inserts a <key, [x1,y1,x2,y2]> pair in the dictionary.

Parameters

  key | The key of the value to set.
  x1 | The bottom left x value of the rect to be inserted
  y1 | The bottom left y value of the rect to be inserted
  x2 | The top right x value of the rect to be inserted
  y2 | The top right y value of the rect to be inserted

Returns
  A newly created array object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutString() [1/2]

Obj pdftron::SDF::Obj::PutString | ( | const char * | key,
|  | const char * | value )

Inserts a <key, Obj::Type::e_string> pair in the dictionary.

Parameters

  key | The key of the value to set.
  value | The value of the Obj::Type::e_string object to be inserted into the dictionary.

Returns
  A newly created string object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutString() [2/2]

Obj pdftron::SDF::Obj::PutString | ( | const char * | key,
|  | const char * | value,
|  | int | size )

Inserts a <key, Obj::Type::e_string> pair in the dictionary.

Parameters

  key | The key of the value to set.
  value | The buffer used to set the value of the Obj::Type::e_string object to be inserted into the dictionary.
  size | The number of bytes to copy from the 'value' buffer parameter.

Returns
  A newly created string object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ PutText()

Obj pdftron::SDF::Obj::PutText | ( | const char * | key,
|  | const UString & | value )

Inserts a <key, Obj::Type::e_string> pair in the dictionary.

Parameters

  key | The key of the value to set.
  value | The value of the Obj::Type::e_string object to be inserted into the dictionary.

Note
  PutText will create the string object as a 'PDF Text' object.

Returns
  A newly created string object.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream object.

Note
  If a dictionary already contains an entry with the same key, the old entry will be deleted and all DictIterators to this entry will be invalidated.

## ◆ Rename()

bool pdftron::SDF::Obj::Rename | ( | const char * | old_key,
|  | const char * | new_key )

Change the key value of a dictionary entry. The key can't be renamed if another key with the same name already exists in the dictionary. In this case Rename returns false.

Parameters

  old_key | A string representing the key value to be changed.
  new_key | A string representing the key value that the old key is changed into.

Exceptions

  An | Exception is thrown if this is not a dictionary or a stream.

## ◆ SetBool()

void pdftron::SDF::Obj::SetBool | ( | bool | b | ) |

Parameters

  b | - bool value used to set Bool object.

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_bool

## ◆ SetMark()

void pdftron::SDF::Obj::SetMark | ( | bool | mark | ) |

Set the object mark. Mark is a boolean value that can be associated with every indirect object. This is especially useful when an object graph should be traversed and an operation should be performed on each node only once.

Parameters

  mark | boolean value that the object's mark should be set to.

Note
  this method can be invoked on any Obj.

## ◆ SetName()

void pdftron::SDF::Obj::SetName | ( | const char * | name | ) |

Parameters

  name | - value used to set Name object.

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_name

## ◆ SetNumber()

void pdftron::SDF::Obj::SetNumber | ( | double | n | ) |

Parameters

  n | - value used to set Number object.

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_number

## ◆ SetStreamData() [1/2]

void pdftron::SDF::Obj::SetStreamData | ( | const char * | data,
|  | const size_t | data_size,
|  | Filters::Filter | filter_chain = Filters::Filter() )

allows to replace the content stream with a new one without creating a new object

## ◆ SetStreamData() [2/2]

void pdftron::SDF::Obj::SetStreamData | ( | const std::vector< unsigned char > & | data,
|  | Filters::Filter | filter_chain = Filters::Filter() )

## ◆ SetString() [1/2]

void pdftron::SDF::Obj::SetString | ( | const UChar * | value,
|  | size_t | size )

Sets the string object value.

Parameters

  value | - character buffer.
  size | - the size of character buffer.

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_string

## ◆ SetString() [2/2]

void pdftron::SDF::Obj::SetString | ( | const UString & | str | ) |

Sets the string object value.

Parameters

  str | - A Unicode string value.

Exceptions

  An | Exception is thrown if this is not a Obj::Type::e_string

## ◆ Size()

size_t pdftron::SDF::Obj::Size | ( |  | ) | const

Returns
  the 'size' of the object. The definition of 'size' depends on the object type. In particular:
  - For a dictionary or a stream object, the method will return the number of key/value pairs in the dictionary.
  - For an array object the method will return the number of Obj entries in the array.
  - For a string object the method will return the number of bytes in the string buffer.
  - For any other object the method will always return 1.

Note
  this method can be invoked on any Obj.

## ◆ Write()

void pdftron::SDF::Obj::Write | ( | Filters::FilterWriter & | stream | ) |

The function writes the Obj to the output stream

Parameters

  stream | - the input stream where the Obj will be written

Note
  this method can be invoked on any Obj.

The documentation for this class was generated from the following file:

- SDF/Obj.h