MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / copy_page

Method copy_page

src/__init__.py:4316–4339  ·  view source on GitHub ↗

Copy a page within a PDF document. This will only create another reference of the same page object. Args: pno: source page number to: put before this page, '-1' means after last page.

(self, pno: int, to: int =-1)

Source from the content-addressed store, hash-verified

4314 return doc
4315
4316 def copy_page(self, pno: int, to: int =-1):
4317 """Copy a page within a PDF document.
4318
4319 This will only create another reference of the same page object.
4320 Args:
4321 pno: source page number
4322 to: put before this page, '-1' means after last page.
4323 """
4324 if self.is_closed:
4325 raise ValueError("document closed")
4326
4327 page_count = len(self)
4328 if (
4329 pno not in range(page_count)
4330 or to not in range(-1, page_count)
4331 ):
4332 raise ValueError("bad page number(s)")
4333 before = 1
4334 copy = 1
4335 if to == -1:
4336 to = page_count - 1
4337 before = 0
4338
4339 return self._move_copy_page(pno, to, before, copy)
4340
4341 def del_xml_metadata(self):
4342 """Delete XML metadata."""

Callers 1

test_deletionFunction · 0.80

Calls 1

_move_copy_pageMethod · 0.95

Tested by 1

test_deletionFunction · 0.64