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

Method get_cdrawings

src/__init__.py:11445–11474  ·  view source on GitHub ↗

Extract vector graphics ("line art") from the page.

(self, extended=None, callback=None, method=None)

Source from the content-addressed store, hash-verified

11443 return rc
11444
11445 def get_cdrawings(self, extended=None, callback=None, method=None):
11446 """Extract vector graphics ("line art") from the page."""
11447 CheckParent(self)
11448 old_rotation = self.rotation
11449 if old_rotation != 0:
11450 self.set_rotation(0)
11451 page = self.this
11452 if isinstance(page, mupdf.PdfPage):
11453 # Downcast pdf_page to fz_page.
11454 page = mupdf.FzPage(page)
11455 assert isinstance(page, mupdf.FzPage), f'{self.this=}'
11456 clips = True if extended else False
11457 prect = mupdf.fz_bound_page(page)
11458 if 1 or g_use_extra:
11459 rc = extra.get_cdrawings(page, extended, callback, method)
11460 else:
11461 rc = list()
11462 if callable(callback) or method is not None:
11463 dev = JM_new_lineart_device_Device(callback, clips, method)
11464 else:
11465 dev = JM_new_lineart_device_Device(rc, clips, method)
11466 dev.ptm = mupdf.FzMatrix(1, 0, 0, -1, 0, prect.y1)
11467 mupdf.fz_run_page(page, dev, mupdf.FzMatrix(), mupdf.FzCookie())
11468 mupdf.fz_close_device(dev)
11469
11470 if old_rotation != 0:
11471 self.set_rotation(old_rotation)
11472 if callable(callback) or method is not None:
11473 return
11474 return rc
11475
11476 def get_contents(self):
11477 """Get xrefs of /Contents objects."""

Callers 4

get_drawingsMethod · 0.95
get_lineartMethod · 0.95
test_drawings1Function · 0.80
test_drawings2Function · 0.80

Calls 3

set_rotationMethod · 0.95
CheckParentFunction · 0.85

Tested by 2

test_drawings1Function · 0.64
test_drawings2Function · 0.64