PdfPageCollection
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 PdfPageCollectionMethods
add
def add(self) -> PdfPageAdds 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) -> PdfPageAdds a new page at the end of the document with the specified dimensions.
Parameters:
| Name | Type | Description |
|---|---|---|
width | float | Width of the new page in points. |
height | float | Height 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) -> PdfPageAdds a new page at the end of the document with a predefined page size.
Parameters:
| Name | Type | Description |
|---|---|---|
page_size | PdfPageSizes | The predefined page size. |
Returns: PdfPage - The newly created . Raises:
SdkException: Thrown when the operation fails.
get_item
def get_item(self, index: int) -> PdfPageReturns the element at the specified index.
Parameters:
| Name | Type | Description |
|---|---|---|
index | int | The 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) -> PdfPageReturns a page by its 1-based page number.
Parameters:
| Name | Type | Description |
|---|---|---|
page_number | int | The 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) -> PdfPageInserts 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. |
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) -> PdfPageInserts a new page at the specified position with the specified dimensions.
Parameters:
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index at which to insert the new page. |
width | float | Width of the new page in points. |
height | float | Height 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) -> PdfPageInserts a new page at the specified position with a predefined page size.
Parameters:
| Name | Type | Description |
|---|---|---|
index | int | The 0-based index at which to insert the new page. |
page_size | PdfPageSizes | The 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) -> NoneMoves 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: Thrown when either index is out of range.SdkException: Thrown when the operation fails.
remove_at
def remove_at(self, index: int) -> NoneRemoves 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: Thrown when index is out of range.SdkException: Thrown when the operation fails.
swap
def swap(self, index1: int, index2: int) -> NoneSwaps 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: Thrown when either index is out of range.SdkException: Thrown when the operation fails.
Properties
count
@propertydef count(self) -> intGets the number of pages in the collection.
Type: int
Read-only property.
enumerator
@propertydef enumerator(self) -> IEnumerator`1Returns an enumerator that iterates through the pages collection.
Type: IEnumerator1`
Read-only property.
first
@propertydef first(self) -> PdfPageGets the first page of the document, or null if the document has no pages.
Type: PdfPage
Read-only property.
last
@propertydef last(self) -> PdfPageGets the last page of the document, or null if the document has no pages.
Type: PdfPage
Read-only property.