PDF Page List Reference¶
- class pdfnaut.page_list.PageList[source]¶
Bases:
MutableSequence[Page]A mutable sequence representing the the pages in a document.
Warning
This class isn’t designed to be constructed by a user. To access the page list of a PDF, use
PdfDocument.pages.- __init__(pdf: PdfParser, root_tree: PdfDictionary, root_tree_ref: PdfReference) None[source]¶
- append(value: Page) None[source]¶
Appends a page
valueto the page list.If appending a page from a different document, please refer to the note in
PageList.insert()for additional considerations.
- count(value: Any) int[source]¶
Returns the amount of times page
valueappears in the page list.This method should in practice always return either 0 (the page is not present) or 1 (the page is present). This method is provided for compatibility with functions expecting mutable sequences.
- extend(values: Iterable[Page]) None[source]¶
Appends a list of pages
valuesinto the page list.When extending, all pages will be copied and inserted into the last page tree within the page list.
If any of the pages belong to a different document, please refer to the note in
PageList.insert()for additional considerations.
- index(value: Any, start: int = 0, stop: int = sys.maxsize) int[source]¶
Returns the index at which page
valuewas first found in the range ofstartincluded tostopexcluded.
- insert(index: int, value: Page) None[source]¶
Inserts a page
valueatindex.indexis the index of the page before which to insert.When inserting, the page object is copied into the page list.
The object identity of the output shall match the identity of the input page. The input page shall receive the indirect reference of the inserted page.
Note
When adding a page belonging to a different document, the page will likely refer to resources that are part of the document such as fonts, images, and annotations.
Some of these resources cannot be reliably copied and so it is possible that they’re not added to the document, in which case, the references of such resources are simply marked null.
Annotations that point to destinations not within the page will be preserved but not in working order. Form objects will not be copied at all.
- pop(index: int = -1) Page[source]¶
Removes the page at
index.Only the page object is removed from the document and its reference is invalidated. The resources used by the page are not removed as they may be used later on in other pages.
- Raises:
IndexError – The page list is empty or the index does not exist.
- Returns:
The page object that was popped.
- Return type:
- remove(value: Page) None[source]¶
Removes the first occurrence of page
valuein the document.- Raises:
IndexError – The page list is empty or the page is not in this document.