PoDoFo  0.9.4
Public Member Functions | List of all members
PoDoFo::PdfPagesTree Class Reference

#include <PdfPagesTree.h>

Inheritance diagram for PoDoFo::PdfPagesTree:
PoDoFo::PdfElement

Public Member Functions

 PdfPagesTree (PdfVecObjects *pParent)
 
 PdfPagesTree (PdfObject *pPagesRoot)
 
virtual ~PdfPagesTree ()
 
int GetTotalNumberOfPages () const
 
PdfPageGetPage (int nIndex)
 
PdfPageGetPage (const PdfReference &ref)
 
void InsertPage (int nAfterPageIndex, PdfObject *pPage)
 
void InsertPage (int nAfterPageIndex, PdfPage *pPage)
 
void InsertPages (int nAfterPageIndex, const std::vector< PdfObject * > &vecPages)
 
PdfPageCreatePage (const PdfRect &rSize)
 
void CreatePages (const std::vector< PdfRect > &vecSizes)
 
PdfPageInsertPage (const PdfRect &rSize, int atIndex)
 
void DeletePage (int inPageNumber)
 
void ClearCache ()
 
- Public Member Functions inherited from PoDoFo::PdfElement
PdfObjectGetObject ()
 
const PdfObjectGetObject () const
 

Additional Inherited Members

- Protected Member Functions inherited from PoDoFo::PdfElement
 PdfElement (const char *pszType, PdfVecObjects *pParent)
 
 PdfElement (const char *pszType, PdfDocument *pParent)
 
 PdfElement (const char *pszType, PdfObject *pObject)
 
 PdfElement (EPdfDataType eExpectedDataType, PdfObject *pObject)
 
const char * TypeNameForIndex (int i, const char **ppTypes, long lLen) const
 
int TypeNameToIndex (const char *pszType, const char **ppTypes, long lLen, int nUnknownValue) const
 
PdfObjectCreateObject (const char *pszType=NULL)
 
PdfObjectGetNonConstObject () const
 

Detailed Description

Class for managing the tree of Pages in a PDF document Don't use this class directly. Use PdfDocument instead.

See also
PdfDocument

Constructor & Destructor Documentation

PoDoFo::PdfPagesTree::PdfPagesTree ( PdfVecObjects pParent)

Construct a new PdfPagesTree

PoDoFo::PdfPagesTree::PdfPagesTree ( PdfObject pPagesRoot)

Construct a PdfPagesTree from the root /Pages object

Parameters
pPagesRootpointer to page tree dictionary
PoDoFo::PdfPagesTree::~PdfPagesTree ( )
virtual

Close/down destruct a PdfPagesTree

Member Function Documentation

void PoDoFo::PdfPagesTree::ClearCache ( )
inline

Clear internal cache of PdfPage objects. All references to PdfPage object will become invalid when calling this method. All PdfPages will be deleted.

You normally will never have to call this method. It is only useful if one modified the page nodes of the pagestree manually.

PdfPage * PoDoFo::PdfPagesTree::CreatePage ( const PdfRect rSize)

Creates a new page object and inserts it into the internal page tree. The returned page is owned by the pages tree and will get deleted along with it!

Parameters
rSizea PdfRect specifying the size of the page (i.e the /MediaBox key) in PDF units
Returns
a pointer to a PdfPage object
void PoDoFo::PdfPagesTree::CreatePages ( const std::vector< PdfRect > &  vecSizes)

Creates several new page objects and inserts them into the internal page tree. The new pages are owned by the pages tree and will get deleted along with it! Note: this function will attach all new pages onto the same page node which can cause the tree to be unbalanced if

Parameters
vecSizesa vector of PdfRect specifying the size of each of the pages to create (i.e the /MediaBox key) in PDF units
void PoDoFo::PdfPagesTree::DeletePage ( int  inPageNumber)

Delete the specified page object from the internal pages tree. It does NOT remove any PdfObjects from memory - just the reference from the tree

Parameters
inPageNumberthe page number (0-based) to be removed

The PdfPage object refering to this page will be deleted by this call! Empty page nodes will also be deleted.

See also
PdfMemDocument::DeletePages
PdfPage * PoDoFo::PdfPagesTree::GetPage ( int  nIndex)

Return a PdfPage for the specified Page index The returned page is owned by the pages tree and deleted along with it.

Parameters
nIndexpage index, 0-based
Returns
a pointer to the requested page
PdfPage * PoDoFo::PdfPagesTree::GetPage ( const PdfReference ref)

Return a PdfPage for the specified Page reference. The returned page is owned by the pages tree and deleted along with it.

Parameters
refthe reference of the pages object
Returns
a pointer to the requested page
int PoDoFo::PdfPagesTree::GetTotalNumberOfPages ( ) const

Return the number of pages in the entire tree

Returns
number of pages
void PoDoFo::PdfPagesTree::InsertPage ( int  nAfterPageIndex,
PdfObject pPage 
)

Inserts an existing page object into the internal page tree. after the specified page number

Parameters
nAfterPageIndexan integer specifying after what page
  • may be one of the special values from EPdfPageInsertionPoint. Pages are 0 based.
pPagemusst be a PdfObject with type /Page
void PoDoFo::PdfPagesTree::InsertPage ( int  nAfterPageIndex,
PdfPage pPage 
)

Inserts an existing page object into the internal page tree. after the specified page number

Parameters
nAfterPageIndexan integer specifying after what page
  • may be one of the special values from EPdfPageInsertionPoint. Pages are 0 based.
pPagea PdfPage to be inserted, the PdfPage will not get owned by the PdfPagesTree
PdfPage * PoDoFo::PdfPagesTree::InsertPage ( const PdfRect rSize,
int  atIndex 
)

Creates a new page object and inserts it at index atIndex. The returned page is owned by the pages tree and will get deleted along with it!

Parameters
rSizea PdfRect specifying the size of the page (i.e the /MediaBox key) in PDF units
atIndexindex where to insert the new page (0-based)
Returns
a pointer to a PdfPage object
void PoDoFo::PdfPagesTree::InsertPages ( int  nAfterPageIndex,
const std::vector< PdfObject * > &  vecPages 
)

Inserts a vector of page objects at once into the internal page tree after the specified page index (zero based index)

Parameters
nAfterPageIndexa zero based integer index specifying after what page to insert
  • you need to pass ePdfPageInsertionPoint_InsertBeforeFirstPage if you want to insert before the first page.
vecPagesmust be a vector of PdfObjects with type /Page