---
title: "PdfPageCollection"
canonical_url: "https://www.nutrient.io/api/python/editors/pdf/pages/pdf-page-collection/"
md_url: "https://www.nutrient.io/api/python/editors/pdf/pages/pdf-page-collection.md"
last_updated: "2026-06-09T10:23:03.737Z"
description: "Represents a collection of pages in a PDF document. Provides indexed access to individual objects and methods to manipulate the page structure."
---

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

```python

from nutrient_sdk import PdfPageCollection

```

## Construction

`PdfPageCollection` cannot be instantiated directly. Obtain instances through static factory methods or via other SDK classes.

## Methods

### add

```python

def add(self) -> PdfPage

```

```python

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

```

```python

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

```

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

**Parameters:**

| Name                     | Type                                                | Description                       |
| ------------------------ | --------------------------------------------------- | --------------------------------- |
| `width` *(optional)*     | `float`                                             | Width of the new page in points.  |
| `height` *(optional)*    | `float`                                             | Height of the new page in points. |
| `page_size` *(optional)* | [`PdfPageSizes`](/api/python/enums/pdf-page-sizes/) | The predefined page size.         |

**Returns:** [`PdfPage`](/api/python/editors/pdf/pages/pdf-page/) - The newly created.

**Raises:**

- [`SdkException`](/api/python/exceptions/sdk-exception/): Thrown when the operation fails.

---

### get_page

```python

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

```

Returns a page by its 1-based page number.

**Parameters:**

| Name          | Type  | Description              |
| ------------- | ----- | ------------------------ |
| `page_number` | `int` | The 1-based page number. |

**Returns:** [`PdfPage`](/api/python/editors/pdf/pages/pdf-page/) - The with the specified page number.

**Raises:**

- [`IndexOutOfBoundsException`](/api/python/exceptions/index-out-of-bounds-exception/): Thrown when pageNumber is out of range.

---

### insert

```python

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

```

```python

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

```

```python

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

```

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

**Parameters:**

| Name                     | Type                                                | Description                                        |
| ------------------------ | --------------------------------------------------- | -------------------------------------------------- |
| `index`                  | `int`                                               | The 0-based index at which to insert the new page. |
| `width` *(optional)*     | `float`                                             | Width of the new page in points.                   |
| `height` *(optional)*    | `float`                                             | Height of the new page in points.                  |
| `page_size` *(optional)* | [`PdfPageSizes`](/api/python/enums/pdf-page-sizes/) | The predefined page size.                          |

**Returns:** [`PdfPage`](/api/python/editors/pdf/pages/pdf-page/) - The newly created.

**Raises:**

- [`IndexOutOfBoundsException`](/api/python/exceptions/index-out-of-bounds-exception/): Thrown when index is out of range.

- [`SdkException`](/api/python/exceptions/sdk-exception/): Thrown when the operation fails.

---

### move_to

```python

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

```

Moves a page from one position to another.

**Parameters:**

| Name                | Type  | Description                                    |
| ------------------- | ----- | ---------------------------------------------- |
| `source_index`      | `int` | The 0-based index of the page to move.         |
| `destination_index` | `int` | The 0-based index of the destination position. |

**Raises:**

- [`IndexOutOfBoundsException`](/api/python/exceptions/index-out-of-bounds-exception/): Thrown when either index is out of range.

- [`SdkException`](/api/python/exceptions/sdk-exception/): Thrown when the operation fails.

---

### remove_at

```python

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

```

Removes the page at the specified 0-based index.

**Parameters:**

| Name    | Type  | Description                              |
| ------- | ----- | ---------------------------------------- |
| `index` | `int` | The 0-based index of the page to remove. |

**Raises:**

- [`IndexOutOfBoundsException`](/api/python/exceptions/index-out-of-bounds-exception/): Thrown when index is out of range.

- [`SdkException`](/api/python/exceptions/sdk-exception/): Thrown when the operation fails.

---

### swap

```python

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

```

Swaps two pages in the document.

**Parameters:**

| Name     | Type  | Description                           |
| -------- | ----- | ------------------------------------- |
| `index1` | `int` | The 0-based index of the first page.  |
| `index2` | `int` | The 0-based index of the second page. |

**Raises:**

- [`IndexOutOfBoundsException`](/api/python/exceptions/index-out-of-bounds-exception/): Thrown when either index is out of range.

- [`SdkException`](/api/python/exceptions/sdk-exception/): Thrown when the operation fails.

---

## Properties

### count

```python

@property
def count(self) -> int

```

The number of pages in the collection.

**Type:** `int`

*Read-only property.*

---

### enumerator

```python

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

```

Returns an enumerator that iterates through the pages collection.

**Type:** `IEnumerator`1`

*Read-only property.*

---

### first

```python

@property
def first(self) -> PdfPage

```

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

**Type:** [`PdfPage`](/api/python/editors/pdf/pages/pdf-page/)

*Read-only property.*

---

### last

```python

@property
def last(self) -> PdfPage

```

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

**Type:** [`PdfPage`](/api/python/editors/pdf/pages/pdf-page/)

*Read-only property.*

---

---

## Related pages

- [All public classes import directly from the top-level package:](/api/python/editors/pdf/pages.md)
- [Pdf Metadata](/api/python/editors/pdf/pages/pdf-metadata.md)
- [Pdf Page](/api/python/editors/pdf/pages/pdf-page.md)

