Represents a collection of pages in a PDF document. Provides indexed access to individual objects and methods to manipulate the page structure.

from nutrient import PdfPageCollection

Methods

add

def add(self) -> PdfPage

Adds a new page at the end of the document with the default A4 page size.

Returns: PdfPage - The newly created . Raises:

  • SdkException: Thrown when the operation fails.

add

def add(self, width: float, height: float) -> PdfPage

Adds a new page at the end of the document with the specified dimensions.

Parameters:

NameTypeDescription
widthfloatWidth of the new page in points.
heightfloatHeight of the new page in points.

Returns: PdfPage - The newly created . Raises:

  • SdkException: Thrown when the operation fails.

add

def add(self, page_size: PdfPageSizes) -> PdfPage

Adds a new page at the end of the document with a predefined page size.

Parameters:

NameTypeDescription
page_sizePdfPageSizesThe predefined page size.

Returns: PdfPage - The newly created . Raises:

  • SdkException: Thrown when the operation fails.

get_item

def get_item(self, index: int) -> PdfPage

Returns the element at the specified index.

Parameters:

NameTypeDescription
indexintThe zero-based index of the element to get.

Returns: PdfPage - The element at the specified index.


get_page

def get_page(self, page_number: int) -> PdfPage

Returns a page by its 1-based page number.

Parameters:

NameTypeDescription
page_numberintThe 1-based page number.

Returns: PdfPage - The with the specified page number. Raises:

  • IndexOutOfBoundsException: Thrown when pageNumber is out of range.

insert

def insert(self, index: int) -> PdfPage

Inserts a new page at the specified position with the default A4 page size.

Parameters:

NameTypeDescription
indexintThe 0-based index at which to insert the new page.

Returns: PdfPage - The newly created . Raises:

  • IndexOutOfBoundsException: Thrown when index is out of range.
  • SdkException: Thrown when the operation fails.

insert

def insert(self, index: int, width: float, height: float) -> PdfPage

Inserts a new page at the specified position with the specified dimensions.

Parameters:

NameTypeDescription
indexintThe 0-based index at which to insert the new page.
widthfloatWidth of the new page in points.
heightfloatHeight of the new page in points.

Returns: PdfPage - The newly created . Raises:

  • IndexOutOfBoundsException: Thrown when index is out of range.
  • SdkException: Thrown when the operation fails.

insert

def insert(self, index: int, page_size: PdfPageSizes) -> PdfPage

Inserts a new page at the specified position with a predefined page size.

Parameters:

NameTypeDescription
indexintThe 0-based index at which to insert the new page.
page_sizePdfPageSizesThe predefined page size.

Returns: PdfPage - The newly created . Raises:

  • IndexOutOfBoundsException: Thrown when index is out of range.
  • SdkException: Thrown when the operation fails.

move_to

def move_to(self, source_index: int, destination_index: int) -> None

Moves a page from one position to another.

Parameters:

NameTypeDescription
source_indexintThe 0-based index of the page to move.
destination_indexintThe 0-based index of the destination position.

Raises:

  • IndexOutOfBoundsException: Thrown when either index is out of range.
  • SdkException: Thrown when the operation fails.

remove_at

def remove_at(self, index: int) -> None

Removes the page at the specified 0-based index.

Parameters:

NameTypeDescription
indexintThe 0-based index of the page to remove.

Raises:

  • IndexOutOfBoundsException: Thrown when index is out of range.
  • SdkException: Thrown when the operation fails.

swap

def swap(self, index1: int, index2: int) -> None

Swaps two pages in the document.

Parameters:

NameTypeDescription
index1intThe 0-based index of the first page.
index2intThe 0-based index of the second page.

Raises:

  • IndexOutOfBoundsException: Thrown when either index is out of range.
  • SdkException: Thrown when the operation fails.

Properties

count

@property
def count(self) -> int

Gets the number of pages in the collection.

Type: int

Read-only property.


enumerator

@property
def enumerator(self) -> IEnumerator`1

Returns an enumerator that iterates through the pages collection.

Type: IEnumerator1`

Read-only property.


first

@property
def first(self) -> PdfPage

Gets the first page of the document, or null if the document has no pages.

Type: PdfPage

Read-only property.


last

@property
def last(self) -> PdfPage

Gets the last page of the document, or null if the document has no pages.

Type: PdfPage

Read-only property.