PoDoFo  1.0.0-dev
Public Types | Public Member Functions | Friends | List of all members
PoDoFo::PdfPageCollection Class Referencefinal

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

#include <PdfPageCollection.h>

Inherits PoDoFo::PdfDictionaryElement.

Public Types

using PageList = std::vector< PdfPage * >
 
using iterator = Iterator< PdfPage, PageList::iterator >
 
using const_iterator = Iterator< const PdfPage, PageList::const_iterator >
 

Public Member Functions

 PdfPageCollection (PdfDocument &doc)
 Construct a new PdfPageTree.
 
 PdfPageCollection (PdfObject &pagesRoot)
 Construct a PdfPageTree from the root /Pages object. More...
 
virtual ~PdfPageCollection ()
 Close/down destruct a PdfPageTree.
 
unsigned GetCount () const
 Return the number of pages in document. More...
 
PdfPageGetPageAt (unsigned index)
 Return a PdfPage for the specified Page index The returned page is owned by the pages tree and deleted along with it. More...
 
const PdfPageGetPageAt (unsigned index) const
 
PdfPageGetPage (const PdfReference &ref)
 Return a PdfPage for the specified Page reference. More...
 
const PdfPageGetPage (const PdfReference &ref) const
 
PdfPageCreatePage (const nullable< Rect > &size=nullptr)
 Creates a new page object and inserts it into the internal page tree. More...
 
PdfPageCreatePage (PdfPageSize pageSize)
 
PdfPageCreatePageAt (unsigned atIndex, const nullable< Rect > &size=nullptr)
 Creates a new page object and inserts it at index atIndex. More...
 
PdfPageCreatePageAt (unsigned atIndex, PdfPageSize pageSize)
 
void CreatePagesAt (unsigned atIndex, unsigned count, const nullable< Rect > &size=nullptr)
 Create count new page objects and insert at the index atIndex. More...
 
void CreatePagesAt (unsigned atIndex, unsigned count, PdfPageSize pageSize)
 
void AppendDocumentPages (const PdfDocument &doc)
 Appends another PdfDocument to this document. More...
 
void AppendDocumentPages (const PdfDocument &doc, unsigned pageIndex, unsigned pageCount)
 Copies one or more pages from another PdfMemDocument to this document. More...
 
void InsertDocumentPageAt (unsigned atIndex, const PdfDocument &doc, unsigned pageIndex)
 Inserts existing page from another PdfDocument to this document. More...
 
void RemovePageAt (unsigned atIndex)
 Delete the specified page object from the internal pages tree. More...
 
void FlattenStructure ()
 Flatten the document page structure tree. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 

Friends

class PdfDocument
 
class PdfPage
 

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

◆ PdfPageCollection()

PdfPageCollection::PdfPageCollection ( PdfObject pagesRoot)

Construct a PdfPageTree from the root /Pages object.

Parameters
pagesRootpointer to page tree dictionary

Member Function Documentation

◆ AppendDocumentPages() [1/2]

void PdfPageCollection::AppendDocumentPages ( const PdfDocument doc)

Appends another PdfDocument to this document.

Parameters
docthe document to append

◆ AppendDocumentPages() [2/2]

void PdfPageCollection::AppendDocumentPages ( const PdfDocument doc,
unsigned  pageIndex,
unsigned  pageCount 
)

Copies one or more pages from another PdfMemDocument to this document.

Parameters
docthe document to append
atIndexthe first page number to copy (0-based)
pageCountthe number of pages to copy

◆ CreatePage()

PdfPage & PdfPageCollection::CreatePage ( const nullable< Rect > &  size = nullptr)

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
sizea Rect specifying the size of the page (i.e the /MediaBox key) in PDF units
Returns
a pointer to a PdfPage object

◆ CreatePageAt()

PdfPage & PdfPageCollection::CreatePageAt ( unsigned  atIndex,
const nullable< Rect > &  size = nullptr 
)

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
sizea Rect 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

◆ CreatePagesAt()

void PdfPageCollection::CreatePagesAt ( unsigned  atIndex,
unsigned  count,
const nullable< Rect > &  size = nullptr 
)

Create count new page objects and insert at the index atIndex.

This is significantly faster than calling CreatePageAt repeatedly.

Parameters
sizea Rect specifying the size of the page (i.e the /MediaBox key) in PDF units
countnumber of pages to create
atIndexindex where to insert the new page (0-based)

◆ FlattenStructure()

void PdfPageCollection::FlattenStructure ( )

Flatten the document page structure tree.

This copy pages inheritable attributes and remove intermediate /Pages nodes. This operation is allowed by the PDF specification, see "ISO 32000-2:2020, 7.7.3.2 Page tree nodes"

◆ GetCount()

unsigned PdfPageCollection::GetCount ( ) const

Return the number of pages in document.

Returns
number of pages

◆ GetPage()

PdfPage & PdfPageCollection::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

◆ GetPageAt()

PdfPage & PdfPageCollection::GetPageAt ( unsigned  index)

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

Parameters
indexpage index, 0-based
Returns
a pointer to the requested page

◆ InsertDocumentPageAt()

void PdfPageCollection::InsertDocumentPageAt ( unsigned  atIndex,
const PdfDocument doc,
unsigned  pageIndex 
)

Inserts existing page from another PdfDocument to this document.

Parameters
atIndexindex at which to add the page in this document
docthe document to append from
pageIndexindex of page to append from doc

◆ RemovePageAt()

void PdfPageCollection::RemovePageAt ( unsigned  atIndex)

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
atIndexthe page number (0-based) to be removed

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

See also
PdfMemDocument::DeletePages

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