pdfobjects::utils Namespace Reference

Classes

class  IAnnotInitializator
class  UniversalAnnotInitializer
class  TextAnnotInitializer
class  LinkAnnotInitializer
class  PropertyEquals
class  IdCollector
class  IndComparator
class  Delinearizator
class  Flattener
struct  OperationStep
struct  OperationScope
class  IProgressBar
class  ProgressObserver
class  FilterStreamWriter
class  NullFilterStreamWriter
class  ZlibFilterStreamWriter
class  IPdfWriter
class  OldStylePdfWriter
struct  FileStreamData
class  FileStreamDataDeleter
class  PdfDocumentWriter

Typedefs

typedef unsigned char *(* stream_data_extractor )(const Object &obj, size_t &size)
typedef observer::IObserver
< OperationStep
PdfWriterObserver

Enumerations

enum  PageTreeNodeType {
  ErrorNode, UnknownNode, LeafNode, InterNode,
  RootNode
}

Functions

CAnnotation::AnnotType annotTypeMapping (const std::string &typeName)
template<PropertyType Tp, typename T >
void complexValueFromXpdfObj (IProperty &ip, const ::Object &obj, T val)
template<typename T >
void complexValueToString (const typename T::Value &val, std::string &str)
template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType getSimpleValueFromArray (const boost::shared_ptr< CArray > &array, size_t position) DEPRECATED
template<typename ItemType >
ItemType::Value getSimpleValueFromArray (const boost::shared_ptr< CArray > &array, size_t position)
template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType getSimpleValueFromArray (const boost::shared_ptr< IProperty > &array, size_t position) DEPRECATED
template<typename ItemType >
ItemType::Value getSimpleValueFromArray (const boost::shared_ptr< IProperty > &ip, size_t position)
template<typename IP >
CInt::Value getIntFromArray (const IP &ip, size_t position)
template<typename IP >
CReal::Value getDoubleFromArray (const IP &ip, size_t position)
template<typename IP >
CString::Value getStringFromArray (const IP &ip, size_t position)
template<typename IP >
CRef::Value getRefFromArray (const IP &ip, size_t position)
template<typename Value , typename ItemType , PropertyType ItemPType>
void setSimpleValueInArray (const CArray &array, size_t position, const Value &val) DEPRECATED
template<typename ItemType >
void setSimpleValueInArray (const CArray &array, size_t position, const typename ItemType::Value &val)
template<typename Value , typename ItemType , PropertyType ItemPType>
void setSimpleValueInArray (const IProperty &array, size_t position, const Value &val) DEPRECATED
template<typename ItemType >
void setSimpleValueInArray (const IProperty &ip, size_t position, const typename ItemType::Value &val)
template<typename IP >
void setIntInArray (const IP &ip, size_t position, int val)
template<typename IP >
void setDoubleInArray (const IP &ip, size_t position, double val)
template<typename ItemType , PropertyType ItemPType>
boost::shared_ptr< ItemType > getTypeFromArray (const boost::shared_ptr< CArray > &array, size_t pos) DEPRECATED
template<typename ItemType >
boost::shared_ptr< ItemType > getTypeFromArray (const boost::shared_ptr< CArray > &array, size_t pos)
template<typename ItemType , PropertyType ItemPType>
boost::shared_ptr< ItemType > getTypeFromArray (const boost::shared_ptr< IProperty > &array, size_t pos) DEPRECATED
template<typename ItemType >
boost::shared_ptr< ItemType > getTypeFromArray (const boost::shared_ptr< IProperty > &ip, size_t pos)
void dictFromXpdfObj (CDict &resultDict,::Object &dict)
size_t stringToCharBuffer (Object &stringObject, CharBuffer &outputBuf)
unsigned char * bufferFromStream (Stream &str, size_t dictLength, size_t &size)
unsigned char * convertStreamToDecodedData (const Object &obj, size_t &size)
size_t streamToCharBuffer (const Object &streamObject, Ref *ref, CharBuffer &outputBuf, stream_data_extractor extractor)
void xpdfObjToString (Object &obj, std::string &str)
void getStringFromXpdfStream (std::string &str,::Object &obj)
void createIndirectObjectStringFromString (const IndiRef &rf, const std::string &val, std::string &output)
template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType getSimpleValueFromDict (const boost::shared_ptr< CDict > &dict, const std::string &id) DONOTUSE
template<typename ItemType >
ItemType::Value getSimpleValueFromDict (const boost::shared_ptr< CDict > &dict, CDict::PropertyId id)
template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType getSimpleValueFromDict (const CDict &dict, const std::string &id) DONOTUSE
template<typename ItemType >
ItemType::Value getSimpleValueFromDict (const CDict &dict, const std::string &id)
template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType getSimpleValueFromDict (const boost::shared_ptr< IProperty > &dict, const std::string &id) DONOTUSE
template<typename ItemType >
ItemType::Value getSimpleValueFromDict (const boost::shared_ptr< IProperty > &ip, const std::string &id)
template<typename IP >
int getIntFromDict (const IP &ip, const std::string &id)
template<typename IP >
double getDoubleFromDict (const IP &ip, const std::string &id)
template<typename IP >
std::string getStringFromDict (const IP &ip, const std::string &id)
template<typename IP >
std::string getNameFromDict (const IP &ip, const std::string &id)
template<typename Value , typename ItemType , PropertyType ItemPType>
void setSimpleValueInDict (const CDict &dict, const std::string &name, const Value &val) DONOTUSE
template<typename ItemType >
void setSimpleValueInDict (const CDict &dict, CDict::PropertyId name, const typename ItemType::Value &val)
template<typename Value , typename ItemType , PropertyType ItemPType>
void setSimpleValueInDict (const IProperty &dict, const std::string &name, const Value &val) DONOTUSE
template<typename ItemType >
void setSimpleValueInDict (const IProperty &ip, CDict::PropertyId name, const typename ItemType::Value &val)
template<typename IP >
void setIntInDict (const IP &ip, const std::string &name, int val)
template<typename IP >
void setDoubleInDict (const IP &ip, const std::string &name, double val)
template<typename ItemType , PropertyType ItemPType>
boost::shared_ptr< ItemType > getTypeFromDictionary (const boost::shared_ptr< CDict > &dict, const std::string &key) DONOTUSE
template<typename ItemType >
boost::shared_ptr< ItemType > getTypeFromDictionary (const boost::shared_ptr< CDict > &dict, CDict::PropertyId key)
template<typename ItemType , PropertyType ItemPType>
boost::shared_ptr< ItemType > getTypeFromDictionary (const boost::shared_ptr< IProperty > &dict, const std::string &key) DONOTUSE
template<typename ItemType >
boost::shared_ptr< ItemType > getTypeFromDictionary (const boost::shared_ptr< IProperty > &ip, CDict::PropertyId key)
template<typename IP >
boost::shared_ptr< CDictgetCDictFromDict (IP &ip, const std::string &key)
template<typename IP >
boost::shared_ptr< CArraygetCArrayFromDict (IP &ip, const std::string &key)
boost::shared_ptr< CDictgetCDictFromDict (boost::shared_ptr< CDict > dict, const std::string &key)
bool objHasParent (const IProperty &ip, boost::shared_ptr< IProperty > &indiObj)
bool objHasParent (const IProperty &ip)
template<typename T >
void parseStreamToContainer (T &container, const ::Object &obj)
template void parseStreamToContainer< CStream::Buffer > (CStream::Buffer &container, const ::Object &obj)
template<typename ITERATOR , typename OUTITERATOR >
void streamToString (const std::string &strDict, ITERATOR begin, ITERATOR end, OUTITERATOR out)
template void streamToString< CStream::Buffer::const_iterator, std::back_insert_iterator< std::string > > (const std::string &strDict, CStream::Buffer::const_iterator begin, CStream::Buffer::const_iterator end, std::back_insert_iterator< std::string > out)
void simpleValueFromString (const std::string &str, bool &val)
void simpleValueFromString (const std::string &str, int &val)
void simpleValueFromString (const std::string &str, double &val)
void simpleValueFromString (const std::string &str, std::string &val)
void simpleValueFromString (const std::string &str, IndiRef &val)
template<>
void simpleValueToString< pBool > (bool val, string &str)
template<>
void simpleValueToString< pInt > (int val, string &str)
void trim_trailing_zero (char *number_str)
template<>
void simpleValueToString< pReal > (double val, string &str)
template<>
void simpleValueToString< pNull > (const NullType &, string &str)
template<>
void simpleValueToString< pRef > (const IndiRef &ref, string &str)
bool isBinaryString (const std::string &val)
template<typename Iter >
std::string makeHexString (Iter it, Iter end)
template<PropertyType Tp>
void simpleValueToString (const std::string &val, std::string &str)
template void simpleValueToString< pString > (const string &val, string &str)
template void simpleValueToString< pName > (const string &val, string &str)
template<>
void complexValueToString< CArray > (const CArray::Value &val, string &str)
template<>
void complexValueToString< CDict > (const CDict::Value &val, string &str)
void xpdfObjToString (Object &obj, string &str)
IPropertycreateObjFromXpdfObj (boost::shared_ptr< CPdf > pdf, const Object &obj, const IndiRef &ref)
IPropertycreateObjFromXpdfObj (const Object &obj)
template<PropertyType Tp, typename T >
Object * simpleValueToXpdfObj (T val)
template Object * simpleValueToXpdfObj< pBool, const bool & > (const bool &val)
template Object * simpleValueToXpdfObj< pInt, const int & > (const int &val)
template Object * simpleValueToXpdfObj< pReal, const double & > (const double &val)
template Object * simpleValueToXpdfObj< pString, const string & > (const string &val)
template Object * simpleValueToXpdfObj< pName, const string & > (const string &val)
template Object * simpleValueToXpdfObj< pNull, const NullType & > (const NullType &val)
template Object * simpleValueToXpdfObj< pRef, const IndiRef & > (const IndiRef &val)
template<PropertyType Tp, typename T >
void simpleValueFromXpdfObj (const Object &obj, T val)
template<>
void simpleValueFromXpdfObj< pNull, NullType & > (const Object &, NullType &)
template<PropertyType Tp, typename T >
void complexValueFromXpdfObj (IProperty &ip, const Object &obj, T val)
template void complexValueFromXpdfObj< pArray, CArray::Value & > (IProperty &ip, const Object &obj, CArray::Value &val)
template void complexValueFromXpdfObj< pDict, CDict::Value & > (IProperty &ip, const Object &obj, CDict::Value &val)
::Object * xpdfObjFromString (const std::string &str, XRef *xref)
::Object * xpdfStreamObjFromBuffer (const CStream::Buffer &buffer, const CDict &dict)
int getIntFromDict (std::string name, boost::shared_ptr< CDict > dict)
IndiRef getRefFromDict (std::string name, boost::shared_ptr< CDict > dict)
std::string getStringFromDict (std::string name, boost::shared_ptr< CDict > dict)
std::string getNameFromDict (std::string name, boost::shared_ptr< CDict > dict)
std::string getDictType (boost::shared_ptr< CDict > dict)
boost::shared_ptr< CDictgetDictFromRef (boost::shared_ptr< IProperty > refProp)
boost::shared_ptr< CDictgetDictFromRef (CPdf &pdf, IndiRef ref)
void printProperty (boost::shared_ptr< IProperty > ip, std::ostream &out)
template<typename SimpleClass , PropertyType SimpleType>
bool simpleEquals (const boost::shared_ptr< IProperty > &val1, const boost::shared_ptr< IProperty > &val2) throw ()
boost::shared_ptr< IPropertygetReferencedObject (boost::shared_ptr< IProperty > ip)
boost::shared_ptr< IPropertygetIPropertyFromRectangle (const libs::Rectangle &rect)
void getRectangleFromProperty (const shared_ptr< IProperty > prop, libs::Rectangle &rect)
boost::shared_ptr< IPropertygetIPropertyFromDate (const tm *time)
bool checkAndReplace (boost::shared_ptr< CDict > annotDict, std::string fieldName, IProperty &fieldValue)
::XRef * getXRef (shared_ptr< IProperty > ip)
template<typename Complex , typename Container >
void getPropertyId (const boost::shared_ptr< Complex > &parent, const boost::shared_ptr< IProperty > &child, Container &container) throw ()
void getRectangleFromProperty (const boost::shared_ptr< IProperty > prop, libs::Rectangle &rect)
template<typename Container >
void getAllChildrenOfPdfObject (boost::shared_ptr< CDict > topdict, Container &cont)
::XRef * getXRef (boost::shared_ptr< IProperty > ip)
template<typename Iter >
std::string makeNamePdfValid (Iter it, Iter end)
std::string makeNamePdfValid (const char *str)
template<typename Iter >
std::string makeStringPdfValid (Iter it, Iter end)
std::string makeStringPdfValid (GString *str)
IPropertycreateObjFromXpdfObj (boost::shared_ptr< CPdf > pdf, const ::Object &obj, const IndiRef &ref)
IPropertycreateObjFromXpdfObj (const ::Object &obj)
template<PropertyType Tp, typename T >
void simpleValueFromXpdfObj (const ::Object &obj, T val)
::Object * xpdfObjFromString (const std::string &str,::XRef *xref=NULL)
template<PropertyType Tp>
void simpleValueToString (bool val, std::string &str)
template<PropertyType Tp>
void simpleValueToString (int val, std::string &str)
template<PropertyType Tp>
void simpleValueToString (double val, std::string &str)
template<PropertyType Tp>
void simpleValueToString (const NullType &val, std::string &str)
template<PropertyType Tp>
void simpleValueToString (const IndiRef &val, std::string &str)
template<typename ItemType , PropertyType ItemPType, typename Value >
Value getValueFromSimple (const boost::shared_ptr< IProperty > &ip) DEPRECATED
template<typename ItemType >
ItemType::Value getValueFromSimple (const boost::shared_ptr< IProperty > &ip)
int getIntFromIProperty (const boost::shared_ptr< IProperty > &ip)
double getDoubleFromIProperty (const boost::shared_ptr< IProperty > &ip)
std::string getStringFromIProperty (const boost::shared_ptr< IProperty > &ip)
std::string getNameFromIProperty (const boost::shared_ptr< IProperty > &ip)
template<typename ItemType , PropertyType ItemPType, typename Value >
void setValueToSimple (const boost::shared_ptr< IProperty > &ip, const Value &val)
ostream & operator<< (ostream &stream, PageTreeNodeType nodeType)
shared_ptr< CDictgetPageTreeRoot (const boost::shared_ptr< CPdf > &pdf)
PageTreeNodeType getNodeType (const boost::shared_ptr< IProperty > &nodeProp) throw ()
template<typename Container >
void getKidsFromInterNode (const boost::shared_ptr< CDict > &interNodeDict, Container &container) throw ()
size_t getKidsCount (const boost::shared_ptr< IProperty > &interNodeProp, PageTreeNodeCountCache *cache) throw ()
boost::shared_ptr< CDictfindPageDict (const boost::shared_ptr< CPdf > &pdf, const boost::shared_ptr< IProperty > &pagesDict, size_t startPos, size_t pos, PageTreeNodeCountCache *cache)
size_t searchTreeNode (shared_ptr< const CPdf > pdf, shared_ptr< CDict > superNode, shared_ptr< CDict > node, size_t startValue, PageTreeNodeCountCache *cache)
size_t getNodePosition (const shared_ptr< CPdf > &pdf, const shared_ptr< IProperty > &node, PageTreeNodeCountCache *cache)
bool isNodeDescendant (const boost::shared_ptr< CPdf > &pdf, const IndiRef &parent, const shared_ptr< CDict > &child)
bool isEncrypted (const boost::shared_ptr< CPdf > &pdf)
size_t getNodePosition (const boost::shared_ptr< CPdf > &pdf, const boost::shared_ptr< IProperty > &node, PageTreeNodeCountCache *cache)
bool isNodeDescendant (const boost::shared_ptr< CPdf > &pdf, const IndiRef &parent, const boost::shared_ptr< CDict > &child)
template<typename CType >
boost::shared_ptr< CType > getCObjectFromRef (const boost::shared_ptr< IProperty > &refProp)
template<typename CType >
boost::shared_ptr< CType > getCObjectFromRef (const IndiRef &ref, const boost::shared_ptr< CPdf > &pdf)
template<typename Iter >
void makeStreamPdfValid (Iter it, Iter end, std::string &out)
template<typename IP >
boost::shared_ptr< CStreamgetCStreamFromDict (IP &ip, const std::string &key)
template<typename IP >
boost::shared_ptr< CStreamgetCStreamFromArray (IP &ip, size_t pos)
int getFiltersFromStream (const Object &obj, std::vector< std::string > &filters)
boost::shared_ptr
< FilterStreamWriter
lookupFilterStreamWriter (const Object &obj, FilterStreamWriter::WritersList &filters)
void writeObject (const ::Object &obj, StreamWriter &stream,::Ref *ref, bool indirect)
void stripXRefStreamFields (const Object &trailer)
bool checkLinearized (StreamWriter &stream, CXref *xref, Ref *ref)
bool isLatestRevision (const XRefWriter &xref)
bool canChangeTrailerEntry (const char *name)
bool typeSafeTrailerEntry (const char *name,::Object &value, XRef &xref)

Detailed Description

Namespace includes all helper functions and classes.


Typedef Documentation

Type for pdf writer observers.

Uses OperationStep as value keeper.

typedef unsigned char*(* pdfobjects::utils::stream_data_extractor)(const Object &obj, size_t &size)

Function to be used for data extracting from the given stream object. Note that implementation can apply additional filters to the stream data currently stored in the obj.stream and update object accordingly (change Filter and associated entry). Length entry doesn't have to be changed by the implementation as it is supposed to be updated by caller (because we want to prevent useless object updating when a chain of this function is called for multiple filters).
Function is called from the streamToCharBuffer function to have transparent access to the stream data without any knowledge about filters. bufferFromStreamData is the referencial implementation which provides encoded data without any filters applied (all other implementations can use this function as the base and convert returned buffer into their represenation).

Parameters:
Stream object.
size Number of bytes written to the returned buffer.
Returns:
Buffer (size bytes) with data (must be deallocated by caller) or NULL on error.

Enumeration Type Documentation

Type enumeration for page tree nodes. Type of dictionary in page tree. Possible values are:

  • ErrorNode - node has bad type (it is not dictionary or reference to dictionary).
  • UnknownNode - node is dictionary but it is not possible to get node type
  • LeafNode - leaf tree node (Page dictionary).
  • InterNode - intermediate node (Pages dictionary).
  • RootNode - intermediate root node.

Implementation node:
Note that order is significant, because we assume that everything lower than LeafNode is kind of error (problem) and also that greater or equal than InterNode is intermediate node.

Enumerator:
ErrorNode 
UnknownNode 
LeafNode 
InterNode 
RootNode 

Function Documentation

CAnnotation::AnnotType pdfobjects::utils::annotTypeMapping ( const std::string &  typeName  ) 
unsigned char * pdfobjects::utils::bufferFromStream ( Stream &  str,
size_t  dictLength,
size_t &  size 
)

Helper function which returns data from given stream.

Parameters:
str Stream to read (until it returns EOF).
dictLength Initial size reported by the stream dictionary.
size Output size of the buffer.

This is low-level function which simply reads given stream from its beginning until EOF. It can be used to retrieve data from whatever Stream filter stack layer. E.g. if we want to get encoded data we can simply give stream->getBaseStream() as parameter and this function will return buffer as it is written in the file.

Returns:
Buffer with stream data (size will contain number of bytes stored) or NULL on error.

References debug::DBG_CRIT, debug::DBG_DBG, and utilsPrintDbg.

Referenced by convertStreamToDecodedData(), and pdfobjects::utils::NullFilterStreamWriter::null_extractor().

bool pdfobjects::utils::canChangeTrailerEntry ( const char *  name  ) 

Checks whether trailer entry with the following name can be changed.

Parameters:
name Name of the field (must be non NULL).
Returns:
true if the name is not black-listed false otherwise.

Referenced by pdfobjects::XRefWriter::changeTrailer().

bool pdfobjects::utils::checkAndReplace ( boost::shared_ptr< CDict >  annotDict,
std::string  fieldName,
IProperty &  fieldValue 
)

Checks and replaces mapping in given dictionary.

Parameters:
annotDict Dictionary to check.
fieldName Field name to search.
fieldValue New value for this fieldName.

Sets new value of given fieldName field and returns true if this property was replaced, false if it was added.

Returns:
true if given fieldName's value has been overwirten, false otherwise.

Referenced by pdfobjects::CPageAnnots::add(), pdfobjects::utils::LinkAnnotInitializer::operator()(), and pdfobjects::utils::TextAnnotInitializer::operator()().

bool pdfobjects::utils::checkLinearized ( StreamWriter stream,
CXref *  xref,
Ref *  ref 
)

Checks whether given stream is linearized.

Parameters:
stream Pdf stream to read (from the file begin).
xref XRef instance.
ref Pointer to reference where to set object and generation number.

Searches first indirect object in the stream from the begining and if it is dictionary, checks whether it contains Linearized version entry. If so returns true and if given ref is not NULL, sets object and generation number. Otherwise just returns false and doesn't care for ref parameter.
This method doesn't check whether credentials are set properly. You have to do it before it is called.

Returns:
true if first indirect object is Linearized dictionary, false otherwise.

Referenced by pdfobjects::utils::Delinearizator::Delinearizator(), and pdfobjects::XRefWriter::XRefWriter().

template<PropertyType Tp, typename T >
void pdfobjects::utils::complexValueFromXpdfObj ( IProperty &  ip,
const Object &  obj,
val 
) [inline]
template<PropertyType Tp, typename T >
void pdfobjects::utils::complexValueFromXpdfObj ( IProperty &  ip,
const ::Object &  obj,
val 
) [inline]

Save real xpdf object value to val.

Parameters:
ip IProperty that will be initialized by obj.
obj Xpdf object which holds the value.
val Variable where the value will be stored.
template void pdfobjects::utils::complexValueFromXpdfObj< pArray, CArray::Value & > ( IProperty &  ip,
const Object &  obj,
CArray::Value &  val 
)
template void pdfobjects::utils::complexValueFromXpdfObj< pDict, CDict::Value & > ( IProperty &  ip,
const Object &  obj,
CDict::Value &  val 
)
template<typename T >
void pdfobjects::utils::complexValueToString ( const typename T::Value &  val,
std::string &  str 
) [inline]

Return complex xpdf object (null,number,string...) in string representation.

REMARK: It is a template function because I think stream won't be converted to string as easily as a dictionary. So we specialize these function for pArray and pDict.

Parameters:
val that will be converted to string.
str string
template<>
void pdfobjects::utils::complexValueToString< CArray > ( const CArray::Value &  val,
string &  str 
) [inline]
template<>
void pdfobjects::utils::complexValueToString< CDict > ( const CDict::Value &  val,
string &  str 
) [inline]
unsigned char * pdfobjects::utils::convertStreamToDecodedData ( const Object &  obj,
size_t &  size 
)

Helper function for removing filters from the given stream object.

Parameters:
obj Stream object.
size Size of returned buffer.
Returns:
Buffer with raw stream data or NULL on error.

If the given obj used some filters, they are all decoded to get orignal data and the stream dictionary is updated so that it doesn't contain any filters.
Stream object stored in the given obj is not touched (because it doesn't give much sense - it returns decoded data anyway, it doesn't use dictionary to find out how to decode). Nevertheless this operation may be considered harmfull for later usage of given the object in the xpdf code paths!

References bufferFromStream(), debug::DBG_DBG, xpdf::freeXpdfObject(), and utilsPrintDbg.

Referenced by pdfobjects::utils::ZlibFilterStreamWriter::deflate().

void pdfobjects::utils::createIndirectObjectStringFromString ( const IndiRef &  rf,
const std::string &  val,
std::string &  output 
)

Create text representation of an indirect object from string and IndiRef.

Parameters:
rf IndiRef.
val Value of an object.
output Output string.

References pdfobjects::Specification::INDIRECT_FOOTER, and pdfobjects::Specification::INDIRECT_HEADER.

Referenced by writeObject().

IProperty* pdfobjects::utils::createObjFromXpdfObj ( const ::Object &  obj  ) 

Creates CObject* from xpdf object.

Parameters:
obj Xpdf object from which the object will be created. Parameter to CObject* constructor.
Returns:
Pointer to newly created object.
IProperty* pdfobjects::utils::createObjFromXpdfObj ( boost::shared_ptr< CPdf >  pdf,
const ::Object &  obj,
const IndiRef &  ref 
)

Creates CObject* from xpdf object.

Parameters:
pdf Pdf in which the created object will live. Parameter to CObject* constructor.
obj Xpdf object from which the object will be created. Parameter to CObject* constructor.
ref Indirect reference number of this object (or its parent).
Returns:
Pointer to newly created object.
IProperty* pdfobjects::utils::createObjFromXpdfObj ( const Object &  obj  ) 
IProperty* pdfobjects::utils::createObjFromXpdfObj ( boost::shared_ptr< CPdf >  pdf,
const Object &  obj,
const IndiRef &  ref 
)
void pdfobjects::utils::dictFromXpdfObj ( CDict &  resultDict,
::Object &  dict 
)

This function is a slower equivalent to complexValueFromXpdfObj. But on the other hand, complexValueFromXpdfObj() needs inner dictionary container that we do not have always access to.

Parameters:
resultDict Dictionary.
dict Xpdf object from which we init dictionary.

References pdfobjects::CDict::addProperty(), createObjFromXpdfObj(), debug::DBG_DBG, pdfobjects::XPdfObjectFactory::getInstance(), pdfobjects::CDict::getPropertyCount(), and utilsPrintDbg.

Referenced by pdfobjects::CInlineImage::CInlineImage().

boost::shared_ptr< CDict > pdfobjects::utils::findPageDict ( const boost::shared_ptr< CPdf > &  pdf,
const boost::shared_ptr< IProperty > &  pagesDict,
size_t  startPos,
size_t  pos,
PageTreeNodeCountCache *  cache 
)

Helper method to find page at certain position.

Parameters:
pdf Pdf instance where to search.
pagesDict Reference to or Page or Pages dictionary representing page node (see Pdf standard notes).
startPos Starting position for searching (see note below).
pos Page position (starting from 1) to find.
cache Cache for reference to page count mapping.

Method recursively goes through page subtree starting with given page tree node until given page position is found or no such position can be found. If position can't be found under given page node, exception is thrown.
If given pagesDict is reference, uses CPdf::getIndirectProperty to get target indirect object, which should be a dictionary (otherwise throws ElementBadTypeException).
Note that this function is not able to handle cycles in page tree and if any occures, endless loop will happen.
startPos stands for position of pagesDict in whole page tree. In fact it is position of first leaf node in subtree.

Pdf standard notes:
Pdf tree structure contains of two types of page dictionaries.

  • Pages dictionary - which is just intermediate node in the tree and contains children nodes. These may be direct pages or another Pages node. It doesn't represent page itself. All children are stored in Kids array. Dictionary also contains Count information which holds number of all Page dictionaries under this node.
  • Page dictionary - leaf node which represents direct page.

This structure is rather complex but enables effective way to access arbitrary page in short time (some applications provide balanced tree form to enable very effective access).

Implementation notes:
Function tries to find page also in page tree structure which doesn't follow pdf specification. All wierd page tree elements are ignored and just those which may stand for intermediate or leaf nodes are condidered. Also doesn't use Count or Parent field information during searching. Uses getKidsCount function to get intermediate leaf nodes count. getKidsCount method requieres also cache which stores already known nodes to their counts mapping. This function just delegates given cache parameter to getPageCount and doesn't care for it much more. If it is NULL, it is not used.

Usage notes:
If searching from begining, page tree root should be used as pagesDict parameter and startPos set to 1.

 Example:
 shared_ptr<CDict> pageTreeRoot=getPageTreeRoot(pdf);
 if(pageTreeRoot.get())
 	findPageDict(pdf, pageTreeRoot, 1, posToSearch, NULL);
 


Searching can start also from different intermediate node than root, but startPos has to be correct position of this node in the tree (same value as returned by getNodePosition method applied on such node). This usage can be used for searching optimization when just part of the tree is searched.

Exceptions:
PageNotFoundException if given position couldn't be found under subtree defined by pagesDict.
ElementBadTypeException if pagesDict is not dictionary or reference to dictionary.
Returns:
Dereferenced page (wrapped in shared_ptr) dictionary at given position.

Referenced by pdfobjects::CPdf::getPage(), pdfobjects::CPdf::insertPage(), and pdfobjects::CPdf::removePage().

template<typename Container >
void pdfobjects::utils::getAllChildrenOfPdfObject ( boost::shared_ptr< CDict >  topdict,
Container &  cont 
) [inline]

Get all children of a tree like structre of pdf objects with, "Prev", Next", "First" dictionary entries. This function can be used e.g. for getting all outlines.

Parameters:
topdict Top level dictionary (it won't be included in the cont).
cont Output container of all children.

Referenced by pdfobjects::CPdf::getOutlines().

template<typename IP >
boost::shared_ptr<CArray> pdfobjects::utils::getCArrayFromDict ( IP &  ip,
const std::string &  key 
) [inline]

Get array from dictionary. If it is an indirect object, fetch the object.

boost::shared_ptr<CDict> pdfobjects::utils::getCDictFromDict ( boost::shared_ptr< CDict >  dict,
const std::string &  key 
) [inline]

Get dictionary from dictionary. If it is an indirect object, fetch the object.

template<typename IP >
boost::shared_ptr<CDict> pdfobjects::utils::getCDictFromDict ( IP &  ip,
const std::string &  key 
) [inline]

Get dictionary from dictionary. If it is an indirect object, fetch the object.

Referenced by pdfobjects::CPageFonts::addSystemType1Font(), pdfobjects::CPageFonts::getFontIdsAndNames(), and pdfobjects::CPdf::getOutlines().

template<typename CType >
boost::shared_ptr<CType> pdfobjects::utils::getCObjectFromRef ( const IndiRef &  ref,
const boost::shared_ptr< CPdf > &  pdf 
) [inline]

Returns cobjects from given reference and pdf.

Parameters:
ref Indirect reference.
pdf CPdf instance where to fetch.

Calls getIndirectProperty on given pdf and cast returned indirect object to given CType (if it has correct type CType::type).

Exceptions:
ElementBadTypeException if indirect object is not CType instance.
Returns:
CType instance wrapped by shared_ptr smart pointer.
template<typename CType >
boost::shared_ptr<CType> pdfobjects::utils::getCObjectFromRef ( const boost::shared_ptr< IProperty > &  refProp  )  [inline]

Returns cobjects from given reference property.

Parameters:
refProp Reference property (must be pRef typed).

Gets reference value from property and dereferences indirect object from it. Uses refProp's pdf for dereference (so it has to be valid). Checks target object type and if it is correct (CType::type), casts it to given CType (uses IProperty::getSmartCObjectPtr).

Exceptions:
ElementBadTypeException if refProp is not CRef instance or indirect object is not CType instance.
Returns:
CType instance wrapped by shared_ptr smart pointer.

References pdfobjects::isRef().

template<typename IP >
boost::shared_ptr<CStream> pdfobjects::utils::getCStreamFromArray ( IP &  ip,
size_t  pos 
) [inline]

Get stream from array. If it is CRef fetch the object pointed at.

Referenced by pdfobjects::CPageContents::parse().

template<typename IP >
boost::shared_ptr<CStream> pdfobjects::utils::getCStreamFromDict ( IP &  ip,
const std::string &  key 
) [inline]

Get stream from dictionary. If it is CRef fetch the object pointed at.

boost::shared_ptr< CDict > pdfobjects::utils::getDictFromRef ( CPdf &  pdf,
IndiRef  ref 
)

Gets dictionary from reference and pdf instance.

Parameters:
pdf Pdf istance.
ref Indirect reference.

Uses CPdf::getIndirectProperty to get dereferenced object from given reference on given pdf instance. Checks object type and if it is CDict, returns it, otherwise throws an axception.

Exceptions:
ElementBadTypeException if indirect object is not CDict instance.
Returns:
CDict instance wrapper by shared_ptr smart pointer.
boost::shared_ptr< CDict > pdfobjects::utils::getDictFromRef ( boost::shared_ptr< IProperty >  refProp  ) 

Gets dictionary from reference property.

Parameters:
refProp Reference property (must be pRef typed).

Gets reference value from property and dereferences indirect object from it. Uses refProp's pdf for dereference. Finaly casts (if indirect is dictionary) to CDict and returns.

Exceptions:
ElementBadTypeException if refProp is not CRef instance or indirect object is not CDict instance.
Returns:
CDict instance wrapper by shared_ptr smart pointer.
std::string pdfobjects::utils::getDictType ( boost::shared_ptr< CDict >  dict  ) 

Gets type of the dictionary.

Parameters:
dict Dictionary wrapped in smart pointer.

Tries to get Type field from dictionary and returns its string value. If not present, returns an empty string.

Returns:
string name of the dictionary type or empty string if not able to find out.
template<typename IP >
CReal::Value pdfobjects::utils::getDoubleFromArray ( const IP &  ip,
size_t  position 
) [inline]
template<typename IP >
double pdfobjects::utils::getDoubleFromDict ( const IP &  ip,
const std::string &  id 
) [inline]

Get double from dictionary.

References getIntFromDict().

double pdfobjects::utils::getDoubleFromIProperty ( const boost::shared_ptr< IProperty > &  ip  )  [inline]

Get double from ip.

References pdfobjects::isInt().

Referenced by pdfobjects::CPageContents::Tm::operator=().

int pdfobjects::utils::getFiltersFromStream ( const Object &  obj,
std::vector< std::string > &  filters 
)

Helper function to get all filters from the stream object.

Parameters:
obj Stream object.
filters Container for filter names.
Returns:
Number of the filters present in the stream or -1 if some of them is not correct.

Referenced by pdfobjects::utils::ZlibFilterStreamWriter::supportObject().

template<typename IP >
CInt::Value pdfobjects::utils::getIntFromArray ( const IP &  ip,
size_t  position 
) [inline]

Get int from array.

Referenced by getDoubleFromArray().

int pdfobjects::utils::getIntFromDict ( std::string  name,
boost::shared_ptr< CDict >  dict 
)

Helper method for getting int property value from dictionary.

Parameters:
name Name of the property in the dictionary.
dict Dictionary where to search.

Gets property according name. Checks property type and if it is realy pInt, gets its int value which is returned.

Exceptions:
ElementNotFoundException if property is not found.
ElementBadTypeException if property is found but doesn't contain integer value.
Returns:
int value of the property.
template<typename IP >
int pdfobjects::utils::getIntFromDict ( const IP &  ip,
const std::string &  id 
) [inline]

Get int from dictionary.

Referenced by getDoubleFromDict().

int pdfobjects::utils::getIntFromIProperty ( const boost::shared_ptr< IProperty > &  ip  )  [inline]

Get int from ip.

boost::shared_ptr< IProperty > pdfobjects::utils::getIPropertyFromDate ( const tm *  time  ) 

Creates property with correct pdf time representation.

Parameters:
time Time to convert.

Created property is an string with ASN.1 defined in ISO/IEC 8824 format used in pdf (see PDF specification page 133 for more information).

boost::shared_ptr< IProperty > pdfobjects::utils::getIPropertyFromRectangle ( const libs::Rectangle &  rect  ) 

Creates property with correct pdf Rectangle representation.

Parameters:
rect Rectangle to convert.

Created property is an array with four elements (see PDF specification page 134 for more information).

Returns:
Property (CArray) wrapped by smart pointer.
size_t pdfobjects::utils::getKidsCount ( const boost::shared_ptr< IProperty > &  interNodeProp,
PageTreeNodeCountCache *  cache 
) throw ()

Calculates number of direct pages under given node property.

Parameters:
interNodeProp Page tree node property (must be dictionary or reference to dictionary).
cache Cache with node reference to leaf page count (if NULL. it is not used).

Checks whether given node is LeafNode and if so, immediatelly returns with 1 (leaf contains one direct page). Otherwise tries to get node dictionary from given property. If not able to do so, returns 0, because this node is probably invalid and so it can't contain any direct page node. Then checks whether given cache parameter is non NULL and if so checks cached value for given node (uses getCachedValue function). If cache entry exists for this node, uses cached value. Otherwise collects all Kids elements from dictionary (uses getKidsFromInterNode function) and calls this function recursively on each reference element. Collected number is returned and if cache is non NULL also caches value (uses updateCache function).
Note that this function never throws.

Referenced by pdfobjects::CPdf::consolidatePageTree(), pdfobjects::CPdf::getPageCount(), and searchTreeNode().

template<typename Container >
void pdfobjects::utils::getKidsFromInterNode ( const boost::shared_ptr< CDict > &  interNodeDict,
Container &  container 
) throw () [inline]

Collects all kids elements from internode dictionary.

Parameters:
interNodeDict Intermediate node dictionary.
container Container where to store kids.

Clears given container at first. Gets Kids array from given dictionary and adds all its elements to given container. If not able to do so, immediatelly returns. Given container is empty if no kid is found (or any other problem occures).
Container template type must store shared_ptr<IProperty> types and support clear and push_back methods.
Note that this function never throws.

Referenced by pdfobjects::CPdf::consolidatePageTree(), and searchTreeNode().

std::string pdfobjects::utils::getNameFromDict ( std::string  name,
boost::shared_ptr< CDict >  dict 
)

Helper method for getting name property value from dictionary.

Parameters:
name Name of the property in the dictionary.
dict Dictionary where to search.

Gets property according name. Checks property type and if it is realy pName, gets its string value which is returned.

Exceptions:
ElementNotFoundException if property is not found.
ElementBadTypeException if property is found but doesn't contain string value.
Returns:
std::string value of the property.
template<typename IP >
std::string pdfobjects::utils::getNameFromDict ( const IP &  ip,
const std::string &  id 
) [inline]

Get name from dictionary.

Referenced by pdfobjects::CPageFonts::getFontIdsAndNames().

std::string pdfobjects::utils::getNameFromIProperty ( const boost::shared_ptr< IProperty > &  ip  )  [inline]

Get name from ip.

size_t pdfobjects::utils::getNodePosition ( const boost::shared_ptr< CPdf > &  pdf,
const boost::shared_ptr< IProperty > &  node,
PageTreeNodeCountCache *  cache 
)

Gets position of given node.

Parameters:
pdf Pdf where to examine.
node Node to find (CRef or CDict instances).
cache Cache for reference to page count mapping.

Starts searching for given node from root of the page tree (returned from getPageTreeRoot function). Uses recursive searchTreeNode function for searching and provides just error handling wrapper to this function. searchTreeNode reqieres also cache which stores already known nodes to their counts mapping. This function just delegates given cache parameter to getPageCount and doesn't care for it much more. If it is NULL, it is not used.
Prefer to use this function instead of searchTreeNode if you are not sure you know what you are doing.

Exceptions:
PageNotFoundException If node can't be found.
ElementBadTypeException If given node is not dictionary or reference to dictionary.
AmbiguousPageTreeException if node position can't be determined bacause of page tree ambiguity (see searchTreeNode for more information).
Returns:
Node position.
size_t pdfobjects::utils::getNodePosition ( const shared_ptr< CPdf > &  pdf,
const shared_ptr< IProperty > &  node,
PageTreeNodeCountCache *  cache 
)
PageTreeNodeType pdfobjects::utils::getNodeType ( const boost::shared_ptr< IProperty > &  nodeProp  )  throw ()

Checks given node for its page tree type.

Parameters:
nodeProp Node property (must be dictionary or reference to dictionary).

Gets node dictionary in first step (either directly from parameter or dereference). If not able to get it, returns ErrorNode type. Then checks whether node dictionary is same as Page tree root node and if so, returns RootNode type. If not able to get root node, returns UnknownNode.
In first step compares dictionary with pageTreeRoot dictionary. If they are same (uses == operator), returns RootNode. Otherwise checks for Type field in node dictionary and if present, checks its value. It must be name object. If so and value is Page, returns LeafNode, or if value is Pages, returns InterNode. Otherwise returns (also if Type field type is not name), returns UnknownNode.
Finally tries to determine node type from existing fields. If dictionary contains Kids array, it is considered to be InterNode. Otherwise returns UnknownNode.
Note that this function never throws.

Returns:
Node type.

Referenced by pdfobjects::CPdf::consolidatePageTree(), and searchTreeNode().

boost::shared_ptr< CDict > pdfobjects::utils::getPageTreeRoot ( const boost::shared_ptr< CPdf > &  pdf  ) 

Gets page tree root node dictionary.

Parameters:
pdf Pdf where to search.

Gets Pages field from pdf dictionary and dereference it to dictionary. If it is not reference or target object is not a dictionary, returns NULL dictionary.
Note that this function never throws.

Returns:
Dictionary wrapped by shared_ptr (NULL dictionary if not found).

Referenced by getNodePosition(), pdfobjects::CPdf::getPage(), pdfobjects::CPdf::getPageCount(), pdfobjects::CPdf::initRevisionSpecific(), pdfobjects::CPdf::insertPage(), pdfobjects::CPdf::removePage(), and pdfobjects::CPdf::unregisterPageObservers().

template<typename Complex , typename Container >
void pdfobjects::utils::getPropertyId ( const boost::shared_ptr< Complex > &  parent,
const boost::shared_ptr< IProperty > &  child,
Container &  container 
) throw () [inline]

Gets all identificators of property in parent complex type.

Parameters:
parent Complex value where to search.
child Property to search.
container Container, where to place all identificators (array indexes).

Uses CObjectComplex::forEach method with IdCollector functor to collect all ids to given container.
Complex template parameter stands for type of CObjectComplex where to search. This type has to provide typedef for propertyId and getAllPropertyNames, getProperty methods.
Container template parameter stands for type of storage where to place found indexes. This has to provide clear and push_back methods. Given container is cleared at start.

References debug::DBG_DBG, and utilsPrintDbg.

void pdfobjects::utils::getRectangleFromProperty ( const boost::shared_ptr< IProperty >  prop,
libs::Rectangle &  rect 
)

Gets rectangle value from given property.

Parameters:
prop Array property with exactly 4 elements.
rect Rectangle which will be filled with values stored in given property.

Array property is transformed into the given rect object.

Exceptions:
CObjBadValue if given property has not valid rectangle representation.
void pdfobjects::utils::getRectangleFromProperty ( const shared_ptr< IProperty >  prop,
libs::Rectangle &  rect 
)
boost::shared_ptr< IProperty > pdfobjects::utils::getReferencedObject ( boost::shared_ptr< IProperty >  ip  ) 
template<typename IP >
CRef::Value pdfobjects::utils::getRefFromArray ( const IP &  ip,
size_t  position 
) [inline]

Get ref from array.

Referenced by pdfobjects::CPageContents::remove().

IndiRef pdfobjects::utils::getRefFromDict ( std::string  name,
boost::shared_ptr< CDict >  dict 
)

Helper method for getting reference property value from dictionary.

Parameters:
name Name of the property in the dictionary.
dict Dictionary where to search.

Gets property according name. Checks property type and if it is realy pRef, gets its IndiRef value which is returned.

Exceptions:
ElementNotFoundException if property is not found.
ElementBadTypeException if property is found but doesn't contain reference value.
Returns:
IndiRef value of the property.
template<typename ItemType >
ItemType::Value pdfobjects::utils::getSimpleValueFromArray ( const boost::shared_ptr< IProperty > &  ip,
size_t  position 
) [inline]

Gets simple value from array. Checks type of given ip and if it is array, casts it to CArray and gets value of property with given position (uses getSimpleValueFromArray with CArray parameter).

Parameters:
ip Array property.
position Array index.
Exceptions:
ElementBadTypeException if given property is not CArray or property with given index is not ItemType.

References pdfobjects::isArray().

template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType pdfobjects::utils::getSimpleValueFromArray ( const boost::shared_ptr< IProperty > &  array,
size_t  position 
) [inline]

Get simple value from array.

Todo:
Can use MPL because ItemType and ItemPType depend on each other.!!
Parameters:
array Array.
position Position in the array.

References pdfobjects::isArray().

template<typename ItemType >
ItemType::Value pdfobjects::utils::getSimpleValueFromArray ( const boost::shared_ptr< CArray > &  array,
size_t  position 
) [inline]

Gets simple value from array. Gets property from given position and uses getValueFromSimple to get its simple value.

Parameters:
array Array property.
position Index in array of property.
Returns:
simple value of property.

References debug::DBG_DBG, and utilsPrintDbg.

template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType pdfobjects::utils::getSimpleValueFromArray ( const boost::shared_ptr< CArray > &  array,
size_t  position 
) [inline]

Get simple value from array.

Todo:
Can use MPL because ItemType and ItemPType depend on each other.!!
Parameters:
array Array.
position Position in the array.

References debug::DBG_DBG, and utilsPrintDbg.

template<typename ItemType >
ItemType::Value pdfobjects::utils::getSimpleValueFromDict ( const boost::shared_ptr< IProperty > &  ip,
const std::string &  id 
) [inline]

Get simple value from dictionary.

Todo:
Can use MPL because ItemType and ItemPType depend on each other.!!
Parameters:
dict Dictionary.
id Position in the dictionary.

References pdfobjects::isDict().

template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType pdfobjects::utils::getSimpleValueFromDict ( const boost::shared_ptr< IProperty > &  dict,
const std::string &  id 
) [inline]

Get simple value from dictionary.

Todo:
Can use MPL because ItemType and ItemPType depend on each other.!!
Parameters:
dict Dictionary.
id Position in the dictionary.

References pdfobjects::isDict().

template<typename ItemType >
ItemType::Value pdfobjects::utils::getSimpleValueFromDict ( const CDict &  dict,
const std::string &  id 
) [inline]

Get simple value from dictionary.

Todo:
Can use MPL because ItemType and ItemPType depend on each other.!!
Parameters:
dict Dictionary.
id Position in the dictionary.

References debug::DBG_DBG, pdfobjects::CDict::getProperty(), getReferencedObject(), and utilsPrintDbg.

template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType pdfobjects::utils::getSimpleValueFromDict ( const CDict &  dict,
const std::string &  id 
) [inline]

Get simple value from dictionary.

Todo:
Can use MPL because ItemType and ItemPType depend on each other.!!
Parameters:
dict Dictionary.
id Position in the dictionary.

References pdfobjects::CDict::getProperty(), and getReferencedObject().

template<typename ItemType >
ItemType::Value pdfobjects::utils::getSimpleValueFromDict ( const boost::shared_ptr< CDict > &  dict,
CDict::PropertyId  id 
) [inline]

Get simple value from dictionary.

Uses getReferencedObject to property with given id to get target property (if it is reference) and getValueFromSimple with target property.

Parameters:
dict Dictionary.
id Position in the dictionary.

References debug::DBG_DBG, getReferencedObject(), and utilsPrintDbg.

template<typename SimpleValueType , typename ItemType , PropertyType ItemPType>
SimpleValueType pdfobjects::utils::getSimpleValueFromDict ( const boost::shared_ptr< CDict > &  dict,
const std::string &  id 
) [inline]

Get simple value from dictionary.

Todo:
Can use MPL because ItemType and ItemPType depend on each other.!!
Parameters:
dict Dictionary.
id Position in the dictionary.

Get simple value from dictionary.

Todo:
Can use MPL because ItemType and ItemPType depend on each other.!!
Parameters:
dict Dictionary.
id Position in the dictionary.

References getReferencedObject().

template<typename IP >
CString::Value pdfobjects::utils::getStringFromArray ( const IP &  ip,
size_t  position 
) [inline]

Get string from array.

std::string pdfobjects::utils::getStringFromDict ( std::string  name,
boost::shared_ptr< CDict >  dict 
)

Helper method for getting string property value from dictionary.

Parameters:
name Name of the property in the dictionary.
dict Dictionary where to search.

Gets property according name. Checks property type and if it is realy pString, gets its string value which is returned.

Exceptions:
ElementNotFoundException if property is not found.
ElementBadTypeException if property is found but doesn't contain string value.
Returns:
std::string value of the property.
template<typename IP >
std::string pdfobjects::utils::getStringFromDict ( const IP &  ip,
const std::string &  id 
) [inline]

Get string from dictionary.

std::string pdfobjects::utils::getStringFromIProperty ( const boost::shared_ptr< IProperty > &  ip  )  [inline]

Get string from ip.

Referenced by pdfobjects::TextSimpleOperator::getRawText().

void pdfobjects::utils::getStringFromXpdfStream ( std::string &  str,
::Object &  obj 
)

Get string from xpdf stream object.

Parameters:
str Output string.
obj Xpdf stream object.
template<typename ItemType >
boost::shared_ptr<ItemType> pdfobjects::utils::getTypeFromArray ( const boost::shared_ptr< IProperty > &  ip,
size_t  pos 
) [inline]

Get iproperty casted to specific type from array.

Checks type of given property and if it pArray, casts it to CArray and uses getTypeFromArray with CArray parameter.

Parameters:
array Array.
id Position in the array.
Exceptions:
ElementBadTypeException if given property is not an array or property at given position doesn't have ItemType type.

References pdfobjects::isArray().

template<typename ItemType , PropertyType ItemPType>
boost::shared_ptr< ItemType > pdfobjects::utils::getTypeFromArray ( const boost::shared_ptr< IProperty > &  array,
size_t  pos 
) [inline]

Get iproperty casted to specific type from array.

Parameters:
array Array.
pos Position in the array.

References pdfobjects::isArray().

template<typename ItemType >
boost::shared_ptr<ItemType> pdfobjects::utils::getTypeFromArray ( const boost::shared_ptr< CArray > &  array,
size_t  pos 
) [inline]

Get iproperty casted to specific type from array.

Parameters:
array Array.
id Position in the array.
Exceptions:
ElementBadTypeException if property doesn't have ItemType type.

References debug::DBG_DBG, getReferencedObject(), and utilsPrintDbg.

template<typename ItemType , PropertyType ItemPType>
boost::shared_ptr< ItemType > pdfobjects::utils::getTypeFromArray ( const boost::shared_ptr< CArray > &  array,
size_t  pos 
) [inline]

Get iproperty casted to specific type from array.

Parameters:
array Array.
pos Position in the array.

References debug::DBG_DBG, getReferencedObject(), and utilsPrintDbg.

template<typename ItemType >
boost::shared_ptr<ItemType> pdfobjects::utils::getTypeFromDictionary ( const boost::shared_ptr< IProperty > &  ip,
CDict::PropertyId  key 
) [inline]

Gets property from dictionary.

Checks type of given ip. If it is CDict instance, casts it and calls getTypeFromDictionary with CDict parameter.

Parameters:
ip Dictionary property.
key Property name.
Returns:
Property with given key and ItemType.
Exceptions:
ElementBadTypeException if given ip is not CDict instance or target property has not ItemType.

References pdfobjects::isDict().

template<typename ItemType , PropertyType ItemPType>
boost::shared_ptr< ItemType > pdfobjects::utils::getTypeFromDictionary ( const boost::shared_ptr< IProperty > &  dict,
const std::string &  key 
) [inline]

Get iproperty casted to specific type from dictionary.

Parameters:
dict Dictionary.
key Position in the dictionary.

References pdfobjects::isDict().

template<typename ItemType >
boost::shared_ptr<ItemType> pdfobjects::utils::getTypeFromDictionary ( const boost::shared_ptr< CDict > &  dict,
CDict::PropertyId  key 
) [inline]

Get property from dictionary.

If property is reference, dereferences it (uses getReferencedObject function).

Parameters:
dict Dictionary property.
key Property name.
Returns:
Property with give type.
Exceptions:
ElementBadTypeException if found (dereferenced) property has different type than given.

References debug::DBG_DBG, getReferencedObject(), and utilsPrintDbg.

template<typename ItemType , PropertyType ItemPType>
boost::shared_ptr< ItemType > pdfobjects::utils::getTypeFromDictionary ( const boost::shared_ptr< CDict > &  dict,
const std::string &  key 
) [inline]

Get iproperty casted to specific type from dictionary.

Parameters:
dict Dictionary.
key Position in the dictionary.

References debug::DBG_DBG, getReferencedObject(), and utilsPrintDbg.

template<typename ItemType >
ItemType::Value pdfobjects::utils::getValueFromSimple ( const boost::shared_ptr< IProperty > &  ip  )  [inline]

Get simple value from simple cobject.

Given property must have correct type (ItemType::type).

Parameters:
ip IProperty.
Returns:
Value.

References debug::DBG_DBG, and utilsPrintDbg.

template<typename ItemType , PropertyType ItemPType, typename Value >
Value pdfobjects::utils::getValueFromSimple ( const boost::shared_ptr< IProperty > &  ip  )  [inline]

Get simple value from simple cobject.

Parameters:
ip IProperty.
Returns:
Value.

References debug::DBG_DBG, and utilsPrintDbg.

::XRef* pdfobjects::utils::getXRef ( boost::shared_ptr< IProperty >  ip  ) 

Get xref from an object.

::XRef* pdfobjects::utils::getXRef ( shared_ptr< IProperty >  ip  ) 
bool pdfobjects::utils::isBinaryString ( const std::string &  val  ) 
bool pdfobjects::utils::isEncrypted ( const boost::shared_ptr< CPdf > &  pdf  ) 

Checks whether file content is encrypted.

Parameters:
pdf Pdf instance to check.

Simple helper which asks its cross reference table.

Returns:
true if file content is encrypted, false otherwise.

Referenced by pdfobjects::CPdf::changeIndirectProperty(), pdfobjects::XRefWriter::changeObject(), pdfobjects::XRefWriter::changeTrailer(), pdfobjects::XRefWriter::cloneRevision(), pdfobjects::XRefWriter::createObject(), and pdfobjects::utils::PdfDocumentWriter::writeDocument().

bool pdfobjects::utils::isLatestRevision ( const XRefWriter &  xref  ) 
bool pdfobjects::utils::isNodeDescendant ( const boost::shared_ptr< CPdf > &  pdf,
const IndiRef &  parent,
const boost::shared_ptr< CDict > &  child 
)

Checks if given child is descendant of node with given reference.

Parameters:
pdf Pdf where to resolv referencies.
parent Reference of the parent.
child Dictionary of page(s) node.

Checks if child's Parent field has same reference as given one as parent parameter. If yes then child dictionary is descendant of node with parent reference. If not, dereference child's parent and continues in recursion using dereferenced parent dictionary as new child for recursion call.
NOTE: this method doesn't perform any checking of parameters and doesn't work if Parent property has not valid value (according page tree state).

Returns:
true If given child belongs to parent subtree, false otherwise.
bool pdfobjects::utils::isNodeDescendant ( const boost::shared_ptr< CPdf > &  pdf,
const IndiRef &  parent,
const shared_ptr< CDict > &  child 
)

References pdfobjects::isRef().

boost::shared_ptr<FilterStreamWriter> pdfobjects::utils::lookupFilterStreamWriter ( const Object &  obj,
FilterStreamWriter::WritersList &  filters 
)

Helper function to find the first filter writer which supports given object.

Parameters:
obj Stream object to write.
filters Container of supported filter writers.
Returns:
Appropriate filter writer or NULL.

Referenced by pdfobjects::utils::FilterStreamWriter::getInstance().

template<typename Iter >
std::string pdfobjects::utils::makeHexString ( Iter  it,
Iter  end 
) [inline]
std::string pdfobjects::utils::makeNamePdfValid ( const char *  str  )  [inline]

Make name valid.

Beginning with PDF 1.2, any character except null (character code 0) may be included in a name by writing its 2-digit hexadecimal code, preceded by the number sign character (#); see implementation notes 3 and 4 in Appendix H. This syntax is required to represent any of the delimiter or white-space characters or the number sign character itself; it is recommended but not required for characters whose codes are outside the range 33 (!) to 126 (~). The examples shown in Table 3.3 are valid literal names in PDF 1.2 and later.

Parameters:
str Character string.

References makeNamePdfValid().

template<typename Iter >
std::string pdfobjects::utils::makeNamePdfValid ( Iter  it,
Iter  end 
) [inline]

Make name valid.

Beginning with PDF 1.2, any character except null (character code 0) may be included in a name by writing its 2-digit hexadecimal code, preceded by the number sign character (#); see implementation notes 3 and 4 in Appendix H. This syntax is required to represent any of the delimiter or white-space characters or the number sign character itself; it is recommended but not required for characters whose codes are outside the range 33 (!) to 126 (~). The examples shown in Table 3.3 are valid literal names in PDF 1.2 and later.

Parameters:
it Start iterator.
end End iterator.

Referenced by makeNamePdfValid().

template<typename Iter >
void pdfobjects::utils::makeStreamPdfValid ( Iter  it,
Iter  end,
std::string &  out 
) [inline]

Make stream pdf valid.

Not needed now.

Parameters:
it Start insert iterator.
end End iterator.
out Output valid string.

Referenced by pdfobjects::CStream::setBuffer().

std::string pdfobjects::utils::makeStringPdfValid ( GString *  str  )  [inline]

Make string pdf valid.

Any characters may appear in a string except unbalanced parentheses and the backslash, which must be treated specially.

Parameters:
str Character string.

References makeStringPdfValid().

template<typename Iter >
std::string pdfobjects::utils::makeStringPdfValid ( Iter  it,
Iter  end 
) [inline]

Make string pdf valid.

Any characters may appear in a string except unbalanced parentheses and the backslash, which must be treated specially.
This includes also (NUL) character, therefore we can't use standard str* functions for strings.

Parameters:
it Start iterator.
end End iterator.

Referenced by makeStringPdfValid().

bool pdfobjects::utils::objHasParent ( const IProperty &  ip  ) 

Returns true if object has a parent.

Exceptions:
ObjInvalidOperation Thrown when the object does not belong to a valid pdf.
Parameters:
ip IProperty of object.
bool pdfobjects::utils::objHasParent ( const IProperty &  ip,
boost::shared_ptr< IProperty > &  indiObj 
)

Returns true if object has a parent.

Exceptions:
ObjInvalidOperation Thrown when the object does not belong to a valid pdf.
Parameters:
ip IProperty of object.
indiObj Out parameter wheren indirect object will be saved, because finding the object can be an expensive operation.

Referenced by pdfobjects::IProperty::dispatchChange().

ostream& pdfobjects::utils::operator<< ( ostream &  stream,
PageTreeNodeType  nodeType 
)

Operator for output stream with PageTreeNodeType enumeration type.

Parameters:
stream Stream, where to print.
nodeType type to print.

Prints human readable from of page tree node enumeration value.

Returns:
reference to given stream.

References ErrorNode, InterNode, LeafNode, RootNode, and UnknownNode.

template<typename T >
void pdfobjects::utils::parseStreamToContainer ( T &  container,
const ::Object &  obj 
) [inline]

Parse stream object to a container

Parameters:
container Container of characters (e.g. ints).
obj Stream object.
template void pdfobjects::utils::parseStreamToContainer< CStream::Buffer > ( CStream::Buffer &  container,
const ::Object &  obj 
)
void pdfobjects::utils::printProperty ( boost::shared_ptr< IProperty >  ip,
std::ostream &  out 
)

Helper method for property printing.

Parameters:
ip Property to print.
out Output stream, where to print (implicit value is std::cout).

Gets string representation of given property and dumps it to standard output. Checks whether this functionality is duplicated.

size_t pdfobjects::utils::searchTreeNode ( shared_ptr< const CPdf >  pdf,
shared_ptr< CDict >  superNode,
shared_ptr< CDict >  node,
size_t  startValue,
PageTreeNodeCountCache *  cache 
)

Searches node in page tree structure.

Parameters:
pdf Pdf where to search.
superNode Page tree node where to search (may be intermediate or leaf).
node Node to search for.
startValue Position of the superNode.
cache Cache for reference to page count mapping.

At first checks if node and superNode are same nodes (uses == operator to compare) and if so, returns startPos. Otherwise tries to get node type (uses getNodeType helper function). In Page case (LeafNode) returns with startValue if given nodes are same or 0 (page not found). This the end of recursion. If it is intermediate node, goes through Kids array and recursively calls this method for each element until recursion returns with non 0 result. This means the end of recursion. startValue is actualized for each Kid's element with 0 recursion return value (Leaf node element increases by 1, intermediate node element by getKidsCount value).
If node is found as direct Kids member (this means that reference of target node is direct member of Kids array), then determines if the node position is unambiguous - checks whether reference to the node is unique in Kids array. If not throws exception. This means that searchTreeNode function is not able to definitively determine node's position.
Function tries to find node position also in page tree structure which doesn't follow pdf specification. All wierd page tree elements are ignored and just those which may stand for intermediate or leaf nodes are considered. Also doesn't use Count and Parent fields information during searching.
Uses getKidsCount function internally to get intermediate leaf nodes count. getKidsCount method requieres also cache parameter which stores already known nodes to their counts mapping. This function just delegates given cache parameter to getPageCount and doesn't care for it much more. Note that if parameter is NULL, cache is not used.

Exceptions:
AmbiguousPageTreeException if page tree is ambiguous and node position can't be determined.
Returns:
Position of the node or 0 if node couldn't be found under this superNode.

References debug::DBG_DBG, debug::DBG_WARN, getKidsCount(), getKidsFromInterNode(), getNodeType(), InterNode, pdfobjects::isRef(), LeafNode, and utilsPrintDbg.

Referenced by getNodePosition().

template<typename IP >
void pdfobjects::utils::setDoubleInArray ( const IP &  ip,
size_t  position,
double  val 
) [inline]

Set double in array.

References setIntInArray().

template<typename IP >
void pdfobjects::utils::setDoubleInDict ( const IP &  ip,
const std::string &  name,
double  val 
) [inline]

Set double in dictioary.

References setIntInDict().

template<typename IP >
void pdfobjects::utils::setIntInArray ( const IP &  ip,
size_t  position,
int  val 
) [inline]

Set int in array.

Referenced by setDoubleInArray().

template<typename IP >
void pdfobjects::utils::setIntInDict ( const IP &  ip,
const std::string &  name,
int  val 
) [inline]

Set int in dictionary.

Referenced by setDoubleInDict().

template<typename ItemType >
void pdfobjects::utils::setSimpleValueInArray ( const IProperty &  ip,
size_t  position,
const typename ItemType::Value &  val 
) [inline]

Sets simple value to array element. Checks given property type and if it is pArray, casts it to CArray and calls setSimpleValueInArray with CArray parameter.

Parameters:
ip Array property.
position Position of element to set.
val Simple value to set.
Exceptions:
ElementBadTypeException if given property is not CArray instance.

References pdfobjects::isArray().

template<typename Value , typename ItemType , PropertyType ItemPType>
void pdfobjects::utils::setSimpleValueInArray ( const IProperty &  array,
size_t  position,
const Value &  val 
) [inline]

Set simple value in array. If it is a reference, set fetch it and set it to the fetched object.

Parameters:
array Array property.
position Position in the array.
val Value to be written.

References pdfobjects::isArray().

template<typename ItemType >
void pdfobjects::utils::setSimpleValueInArray ( const CArray &  array,
size_t  position,
const typename ItemType::Value &  val 
) [inline]

Sets simple value to array element. Uses setValueToSimple function to set property value.

Parameters:
array Array property.
position Position of element to set.
val Simple value to set.

References debug::DBG_DBG, pdfobjects::CArray::getProperty(), getReferencedObject(), and utilsPrintDbg.

template<typename Value , typename ItemType , PropertyType ItemPType>
void pdfobjects::utils::setSimpleValueInArray ( const CArray &  array,
size_t  position,
const Value &  val 
) [inline]

Set simple value in array. If it is a reference, set fetch it and set it to the fetched object.

Parameters:
array Array property.
position Position in the array.
val Value to be written.

References debug::DBG_DBG, pdfobjects::CArray::getProperty(), getReferencedObject(), and utilsPrintDbg.

template<typename ItemType >
void pdfobjects::utils::setSimpleValueInDict ( const IProperty &  ip,
CDict::PropertyId  name,
const typename ItemType::Value &  val 
) [inline]

Set simple value in dictionary. If it is a reference, set fetch it and set it to the fetched object.

Parameters:
dict Dict property.
name Name of property.
val Value to be written.

References pdfobjects::isDict().

template<typename Value , typename ItemType , PropertyType ItemPType>
void pdfobjects::utils::setSimpleValueInDict ( const IProperty &  dict,
const std::string &  name,
const Value &  val 
) [inline]

Set simple value in dictionary. If it is a reference, set fetch it and set it to the fetched object.

Parameters:
dict Dict property.
name Name of property.
val Value to be written.

References pdfobjects::isDict().

template<typename ItemType >
void pdfobjects::utils::setSimpleValueInDict ( const CDict &  dict,
CDict::PropertyId  name,
const typename ItemType::Value &  val 
) [inline]

Sets value of property with given name.

Gets property with given name and dereference (uses getReferencedObject) it (if it is reference) and sets its value (uses setValueToSimple).

Parameters:
dict Dictionary.
name Property name.
val Value for property.

References debug::DBG_DBG, pdfobjects::CDict::getProperty(), getReferencedObject(), and utilsPrintDbg.

template<typename Value , typename ItemType , PropertyType ItemPType>
void pdfobjects::utils::setSimpleValueInDict ( const CDict &  dict,
const std::string &  name,
const Value &  val 
) [inline]

Set simple value in dictionary. If it is a reference, set fetch it and set it to the fetched object.

Parameters:
dict Dict property.
name Name of property.
val Value to be written.

References debug::DBG_DBG, pdfobjects::CDict::getProperty(), getReferencedObject(), and utilsPrintDbg.

template<typename ItemType , PropertyType ItemPType, typename Value >
void pdfobjects::utils::setValueToSimple ( const boost::shared_ptr< IProperty > &  ip,
const Value &  val 
) [inline]

Set simple value.

Parameters:
ip IProperty.
val Value to set.

References debug::DBG_DBG, and utilsPrintDbg.

template<typename SimpleClass , PropertyType SimpleType>
bool pdfobjects::utils::simpleEquals ( const boost::shared_ptr< IProperty > &  val1,
const boost::shared_ptr< IProperty > &  val2 
) throw () [inline]

Compares two simple values.

Parameters:
val1 value to compare.
val2 value to compare.

Helper methods for simple value comparing. Uses getValueFromSimple method to get value from property. Simple properties are same if values, which they holds are same.
SimpleClass template parameter stands for property class type (CRef, CInt, ...)
simpleType is property type - constant value returned by getType() method.

NOTE: no checking of parameters is done here.

void pdfobjects::utils::simpleValueFromString ( const std::string &  str,
IndiRef &  val 
)
void pdfobjects::utils::simpleValueFromString ( const std::string &  str,
std::string &  val 
)
void pdfobjects::utils::simpleValueFromString ( const std::string &  str,
double &  val 
)
void pdfobjects::utils::simpleValueFromString ( const std::string &  str,
int &  val 
)
void pdfobjects::utils::simpleValueFromString ( const std::string &  str,
bool &  val 
)

Parses string to get simple values like int, name, bool etc.

Parameters:
str String to be parsed.
val Desired value.
Exceptions:
ObjBadValueE Thrown when the string, can't be parsed correctly.

Referenced by pdfobjects::CObjectSimple< Tp >::setStringRepresentation().

template<PropertyType Tp, typename T >
void pdfobjects::utils::simpleValueFromXpdfObj ( const ::Object &  obj,
val 
) [inline]

Save real xpdf object value to val.

Parameters:
obj Xpdf object which holds the value.
val Variable where the value will be stored.
template<PropertyType Tp, typename T >
void pdfobjects::utils::simpleValueFromXpdfObj ( const Object &  obj,
val 
) [inline]
template<>
void pdfobjects::utils::simpleValueFromXpdfObj< pNull, NullType & > ( const Object &  ,
NullType &   
) [inline]
template<PropertyType Tp>
void pdfobjects::utils::simpleValueToString ( const IndiRef &  val,
std::string &  str 
) [inline]

template<PropertyType Tp>
void pdfobjects::utils::simpleValueToString ( const NullType &  val,
std::string &  str 
) [inline]

template<PropertyType Tp>
void pdfobjects::utils::simpleValueToString ( double  val,
std::string &  str 
) [inline]

template<PropertyType Tp>
void pdfobjects::utils::simpleValueToString ( int  val,
std::string &  str 
) [inline]

template<PropertyType Tp>
void pdfobjects::utils::simpleValueToString ( bool  val,
std::string &  str 
) [inline]

Return simple xpdf object (null,number,string...) in string representation.

REMARK: String can represent more different objects, so we have to distinguish among them. This is done at compile time with use of templates, but because of this we have to make other functions also template.

Parameters:
val that will be converted to string.
str string.
template<PropertyType Tp>
void pdfobjects::utils::simpleValueToString ( const std::string &  val,
std::string &  str 
) [inline]

template<>
void pdfobjects::utils::simpleValueToString< pBool > ( bool  val,
string &  str 
) [inline]
template<>
void pdfobjects::utils::simpleValueToString< pInt > ( int  val,
string &  str 
) [inline]
template void pdfobjects::utils::simpleValueToString< pName > ( const string &  val,
string &  str 
)
template<>
void pdfobjects::utils::simpleValueToString< pNull > ( const NullType &  ,
string &  str 
) [inline]
template<>
void pdfobjects::utils::simpleValueToString< pReal > ( double  val,
string &  str 
) [inline]
template<>
void pdfobjects::utils::simpleValueToString< pRef > ( const IndiRef &  ref,
string &  str 
) [inline]
template void pdfobjects::utils::simpleValueToString< pString > ( const string &  val,
string &  str 
)

Referenced by stringToCharBuffer().

template<PropertyType Tp, typename T >
Object * pdfobjects::utils::simpleValueToXpdfObj ( val  )  [inline]

Create xpdf Object which represents value.

Parameters:
val Value where the value is stored.
Returns:
Xpdf object where the value is stored.
template Object* pdfobjects::utils::simpleValueToXpdfObj< pBool, const bool & > ( const bool &  val  ) 
template Object* pdfobjects::utils::simpleValueToXpdfObj< pInt, const int & > ( const int &  val  ) 
template Object* pdfobjects::utils::simpleValueToXpdfObj< pName, const string & > ( const string &  val  ) 
template Object* pdfobjects::utils::simpleValueToXpdfObj< pNull, const NullType & > ( const NullType &  val  ) 
template Object* pdfobjects::utils::simpleValueToXpdfObj< pReal, const double & > ( const double &  val  ) 
template Object* pdfobjects::utils::simpleValueToXpdfObj< pRef, const IndiRef & > ( const IndiRef &  val  ) 
template Object* pdfobjects::utils::simpleValueToXpdfObj< pString, const string & > ( const string &  val  ) 
size_t pdfobjects::utils::streamToCharBuffer ( const Object &  streamObject,
Ref *  ref,
CharBuffer outputBuf,
stream_data_extractor  extractor 
)

Makes a valid pdf indirect object representation of stream object.

Parameters:
streamObject Xpdf object representing stream.
ref Reference for this indirect object.
outputBuf Output byte buffer containing complete representation.
extractor Function to be used to extract data from the object's stream.

Allocates and fills buffer in given outputBuf with pdf object format representation of given stream object. Moreover adds indirect header and footer if ref is non NULL.
If you want some filters to be used to encode stream data, use extractor function parameter for this purpose. bufferFromStreamData used by default returns stream data without any filters applied.
Given buffer may contain NUL bytes inside. Caller should consume number of returned bytes from outputBuf.

Returns:
number of bytes used in outputBuf or 0 if problem occures.

References char_buffer_new(), pdfobjects::Specification::CSTREAM_FOOTER, debug::DBG_DBG, debug::DBG_ERR, debug::DBG_WARN, xpdf::freeXpdfObject(), pdfobjects::XPdfObjectFactory::getInstance(), pdfobjects::Specification::INDIRECT_FOOTER, pdfobjects::Specification::INDIRECT_HEADER, utilsPrintDbg, and xpdfObjToString().

Referenced by pdfobjects::utils::ZlibFilterStreamWriter::compress(), and pdfobjects::utils::NullFilterStreamWriter::compress().

template<typename ITERATOR , typename OUTITERATOR >
void pdfobjects::utils::streamToString ( const std::string &  strDict,
ITERATOR  begin,
ITERATOR  end,
OUTITERATOR  out 
) [inline]

CStream object to string

Parameters:
strDict Dictionary string representation.
begin Buffer begin
end Buffer end
out Output string.
template void pdfobjects::utils::streamToString< CStream::Buffer::const_iterator, std::back_insert_iterator< std::string > > ( const std::string &  strDict,
CStream::Buffer::const_iterator  begin,
CStream::Buffer::const_iterator  end,
std::back_insert_iterator< std::string >  out 
)
size_t pdfobjects::utils::stringToCharBuffer ( Object &  stringObject,
CharBuffer outputBuf 
)

Makes a valid pdf representation of xpdf string object.

Parameters:
stringObject Xpdf object with objString type.
outputBuf Output buffer where final representation is stored.

This method creates correct pdf representation of given xpdf string object. It should be used for string objects which may contain NUL characters inside. Otherwise simpleValueToString method can be used.

Returns:
Number of bytes stored in outputBuf.

References char_buffer_new(), debug::DBG_DBG, debug::DBG_ERR, simpleValueToString< pString >(), and utilsPrintDbg.

void pdfobjects::utils::stripXRefStreamFields ( const Object &  trailer  ) 

Helper function for trailer cleanup from xref stream entries.

Parameters:
trailer TrailerClenaup.

Get rid all entries which could come from xref stream dictionary.

References debug::DBG_INFO, xpdf::freeXpdfObject(), and utilsPrintDbg.

Referenced by pdfobjects::utils::OldStylePdfWriter::writeTrailer().

void pdfobjects::utils::trim_trailing_zero ( char *  number_str  ) 

Removes trailing zeros from given number in string form.

Parameters:
number_str Number in string representation.

Note that number must be in [-+]nnnn.nnnn form.

bool pdfobjects::utils::typeSafeTrailerEntry ( const char *  name,
::Object &  value,
XRef &  xref 
)

Checks whether given name, value pair is valid for Trailer entry.

Parameters:
name Name for the Trailer entry (must be non NULL).
value Value to be set for Trailer entry.
xref Xref for value fetching.
Returns:
true if the given pair is valid, false otherwise.

Referenced by pdfobjects::XRefWriter::changeTrailer().

void pdfobjects::utils::writeObject ( const ::Object &  obj,
StreamWriter stream,
::Ref *  ref,
bool  indirect 
)

Helper method for xpdf object writing to the stream.

Parameters:
obj Xpdf object to write.
ref Object's reference (NULL for indirect object).
stream Stream where to write.
indirect Flag for indirect object

Creates correct pdf string representation of given object, adds indirect header and footer if indirect flag is specified and writes everything to the given stream.
Given xpdf object data (like stream or string) can contain unprintable or 0 bytes.

References char_buffer_new(), createIndirectObjectStringFromString(), createObjFromXpdfObj(), pdfobjects::utils::FilterStreamWriter::getInstance(), and StreamWriter::putLine().

Referenced by pdfobjects::utils::OldStylePdfWriter::writeContent(), and pdfobjects::utils::OldStylePdfWriter::writeTrailer().

::Object* pdfobjects::utils::xpdfObjFromString ( const std::string &  str,
::XRef *  xref = NULL 
)

Create xpdf object from string.

Parameters:
str String that should represent an xpdf object.
xref Xref of actual pdf if any.
Returns:
Xpdf object whose string representation is in str.
::Object* pdfobjects::utils::xpdfObjFromString ( const std::string &  str,
XRef *  xref 
)
void pdfobjects::utils::xpdfObjToString ( Object &  obj,
string &  str 
)
void pdfobjects::utils::xpdfObjToString ( Object &  obj,
std::string &  str 
)

Convert xpdf object to string

Parameters:
obj Xpdf object that will be converted.
str This will hold the string representation of the object.

Referenced by streamToCharBuffer().

Object * pdfobjects::utils::xpdfStreamObjFromBuffer ( const CStream::Buffer &  buffer,
const CDict &  dict 
)

Create xpdf object from string.

Parameters:
buffer Stream buffer.
dict Stream dictionary.
Returns:
Xpdf object.

Referenced by pdfobjects::CStream::_makeXpdfObject().