PoDoFo 0.9.20
Classes | Public Member Functions | List of all members
PoDoFo::PdfIndirectObjectList Class Referencefinal

#include <PdfIndirectObjectList.h>

Classes

class  Observer
 
class  StreamFactory
 

Public Member Functions

void SetCanReuseObjectNumbers (bool canReuseObjectNumbers)
 
void Clear ()
 
unsigned GetSize () const
 
unsigned GetObjectCount () const
 
PdfObjectMustGetObject (const PdfReference &ref) const
 
PdfObjectGetObject (const PdfReference &ref) const
 
std::unique_ptr< PdfObjectRemoveObject (const PdfReference &ref)
 
std::unique_ptr< PdfObjectRemoveObject (const iterator &it)
 
std::unique_ptr< PdfObjectReplaceObject (const PdfReference &ref, PdfObject *obj)
 
PdfObjectCreateDictionaryObject (const std::string_view &type={ }, const std::string_view &subtype={ })
 
PdfObjectCreateObject (const PdfObject &obj)
 
void Attach (Observer &observer)
 
void Detach (Observer &observer)
 
void SetStreamFactory (StreamFactory *factory)
 
std::unique_ptr< PdfObjectStreamProvider > CreateStream ()
 
void WriteObject (PdfObject &obj)
 
void Finish ()
 
void BeginAppendStream (PdfObjectStream &stream)
 
void EndAppendStream (PdfObjectStream &stream)
 
void TryIncrementObjectCount (const PdfReference &ref)
 
iterator begin () const
 
iterator end () const
 
PdfDocumentGetDocument () const
 
bool GetCanReuseObjectNumbers () const
 
const ReferenceList & GetFreeObjects () const
 

Detailed Description

A list of PdfObjects that constitutes the indirect object list of the document The PdfParser will read the PdfFile into memory and create a PdfIndirectObjectList of all dictionaries found in the PDF file.

The PdfWriter class contrary creates a PdfIndirectObjectList internally and writes it to a PDF file later with an appropriate table of contents.

This class contains also advanced functions for searching of PdfObject's in a PdfIndirectObjectList.

Member Function Documentation

◆ Attach()

void PdfIndirectObjectList::Attach ( Observer observer)

Attach a new observer

Parameters
observerto attach

◆ begin()

PdfIndirectObjectList::iterator PdfIndirectObjectList::begin ( ) const

Iterator pointing at the beginning of the vector

Returns
beginning iterator

◆ BeginAppendStream()

void PdfIndirectObjectList::BeginAppendStream ( PdfObjectStream stream)

Every stream implementation has to call this in BeginAppend

Parameters
streamthe stream object that is calling

◆ Clear()

void PdfIndirectObjectList::Clear ( )

Removes all objects from the vector and resets it to the default state.

If SetAutoDelete is true all objects are deleted. All observers are removed from the vector.

See also
SetAutoDelete
IsAutoDelete

◆ CreateDictionaryObject()

PdfObject & PdfIndirectObjectList::CreateDictionaryObject ( const std::string_view &  type = { },
const std::string_view &  subtype = { } 
)

Creates a new object and inserts it into the vector. This function assigns the next free object number to the PdfObject.

Parameters
typeoptional value of the /Type key of the object
subtypeoptional value of the /SubType key of the object
Returns
PdfObject pointer to the new PdfObject

◆ CreateObject()

PdfObject & PdfIndirectObjectList::CreateObject ( const PdfObject obj)

Creates a new object and inserts it into the vector. This function assigns the next free object number to the PdfObject.

Parameters
objvalue of the PdfObject
Returns
PdfObject pointer to the new PdfObject

◆ CreateStream()

unique_ptr< PdfObjectStreamProvider > PdfIndirectObjectList::CreateStream ( )

Creates a stream object This method is a factory for PdfObjectStream objects.

Parameters
parentparent object
Returns
a new stream object

◆ Detach()

void PdfIndirectObjectList::Detach ( Observer observer)

Detach an observer.

Parameters
observerobserver to detach

◆ end()

PdfIndirectObjectList::iterator PdfIndirectObjectList::end ( ) const

Iterator pointing at the end of the vector

Returns
ending iterator

◆ EndAppendStream()

void PdfIndirectObjectList::EndAppendStream ( PdfObjectStream stream)

Every stream implementation has to call this in EndAppend

Parameters
streamthe stream object that is calling

◆ Finish()

void PdfIndirectObjectList::Finish ( )

Call whenever a document is finished

◆ GetCanReuseObjectNumbers()

bool PoDoFo::PdfIndirectObjectList::GetCanReuseObjectNumbers ( ) const
inline
Returns
whether can re-use free object numbers when creating new objects.

◆ GetDocument()

PdfDocument & PoDoFo::PdfIndirectObjectList::GetDocument ( ) const
inline
Returns
a pointer to a PdfDocument that is the parent of this vector. Might be nullptr if the vector has no parent.

◆ GetFreeObjects()

const ReferenceList & PoDoFo::PdfIndirectObjectList::GetFreeObjects ( ) const
inline
Returns
a list of free references in this vector

◆ GetObject()

PdfObject * PdfIndirectObjectList::GetObject ( const PdfReference ref) const

Finds the object with the given reference and returns a pointer to it if it is found.

Parameters
refthe object to be found
Returns
the found object or nullptr if no object was found.

◆ GetObjectCount()

unsigned PoDoFo::PdfIndirectObjectList::GetObjectCount ( ) const
inline
Returns
the highest object number in the vector

◆ GetSize()

unsigned PdfIndirectObjectList::GetSize ( ) const
Returns
the size of the internal vector

◆ MustGetObject()

PdfObject & PdfIndirectObjectList::MustGetObject ( const PdfReference ref) const

Finds the object with the given reference and returns a pointer to it if it is found. Throws a PdfError exception with error code ePdfError_NoObject if no object was found

Parameters
refthe object to be found
Returns
the found object
Exceptions
PdfError(ePdfError_NoObject)

◆ RemoveObject() [1/2]

unique_ptr< PdfObject > PdfIndirectObjectList::RemoveObject ( const iterator &  it)

Remove the object with the iterator it from the vector and return it

Parameters
refthe reference of the object to remove
Returns
the removed object

◆ RemoveObject() [2/2]

unique_ptr< PdfObject > PdfIndirectObjectList::RemoveObject ( const PdfReference ref)

Remove the object with the given object and generation number from the list of objects. The object is returned if it was found. Otherwise nullptr is returned. The caller has to delete the object by himself.

Parameters
refthe object to be found
markAsFreeif true the removed object reference is marked as free object you will always want to have this true as invalid PDF files can be generated otherwise
Returns
The removed object.

◆ ReplaceObject()

unique_ptr< PdfObject > PdfIndirectObjectList::ReplaceObject ( const PdfReference ref,
PdfObject obj 
)

Replace the object at the given reference

Parameters
refthe reference of the object to replace
objthe object that will be inserted instead, must be non null
Returns
the replaced object

◆ SetCanReuseObjectNumbers()

void PdfIndirectObjectList::SetCanReuseObjectNumbers ( bool  canReuseObjectNumbers)

Enable/disable object numbers re-use. By default object numbers re-use is enabled.

Parameters
canReuseObjectNumbersif true, free object numbers can be re-used when creating new objects.

If set to false, the list of free object numbers is automatically cleared.

◆ SetStreamFactory()

void PdfIndirectObjectList::SetStreamFactory ( StreamFactory factory)

Sets a StreamFactory which is used whenever CreateStream is called.

Parameters
factorya stream factory or nullptr to reset to the default factory

◆ TryIncrementObjectCount()

void PdfIndirectObjectList::TryIncrementObjectCount ( const PdfReference ref)

Set the object count so that the object described this reference is contained in the object count.

Parameters
refreference of newly added object

◆ WriteObject()

void PdfIndirectObjectList::WriteObject ( PdfObject obj)

Can be called to force objects to be written to disk.

Parameters
obja PdfObject that should be written to disk.