MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / select

Method select

src/__init__.py:6754–6779  ·  view source on GitHub ↗

Build sub-pdf with page numbers in the list.

(self, pyliste)

Source from the content-addressed store, hash-verified

6752 )
6753
6754 def select(self, pyliste):
6755 """Build sub-pdf with page numbers in the list."""
6756 if self.is_closed or self.is_encrypted:
6757 raise ValueError("document closed or encrypted")
6758 if not self.is_pdf:
6759 raise ValueError("is no PDF")
6760 if not hasattr(pyliste, "__getitem__"):
6761 raise ValueError("sequence required")
6762
6763 valid_range = range(len(self))
6764 if (len(pyliste) == 0
6765 or min(pyliste) not in valid_range
6766 or max(pyliste) not in valid_range
6767 ):
6768 raise ValueError("bad page number(s)")
6769
6770 # get underlying pdf document,
6771 pdf = _as_pdf_document(self)
6772 # create page sub-pdf via pdf_rearrange_pages2().
6773 #
6774 # We use PDF_CLEAN_STRUCTURE_KEEP otherwise we lose structure tree
6775 # which, for example, breaks test_3705.
6776 mupdf.pdf_rearrange_pages2(pdf, pyliste, mupdf.PDF_CLEAN_STRUCTURE_KEEP)
6777
6778 # remove any existing pages with their kids
6779 self._reset_page_refs()
6780
6781 def set_language(self, language=None):
6782 pdf = _as_pdf_document(self)

Callers 4

test_deletionFunction · 0.80
test_3150Function · 0.80
get_all_page_from_pdfFunction · 0.80
tFunction · 0.80

Calls 2

_reset_page_refsMethod · 0.95
_as_pdf_documentFunction · 0.85

Tested by 3

test_deletionFunction · 0.64
test_3150Function · 0.64
get_all_page_from_pdfFunction · 0.64