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

Function get_text_selection

src/utils.py:298–314  ·  view source on GitHub ↗
(
    page: pymupdf.Page,
    p1: point_like,
    p2: point_like,
    clip: rect_like = None,
    textpage: pymupdf.TextPage = None,
)

Source from the content-addressed store, hash-verified

296
297
298def get_text_selection(
299 page: pymupdf.Page,
300 p1: point_like,
301 p2: point_like,
302 clip: rect_like = None,
303 textpage: pymupdf.TextPage = None,
304):
305 pymupdf.CheckParent(page)
306 tp = textpage
307 if tp is None:
308 tp = page.get_textpage(clip=clip, flags=pymupdf.TEXT_DEHYPHENATE)
309 elif getattr(tp, "parent") != page:
310 raise ValueError("not a textpage of this page")
311 rc = tp.extractSelection(p1, p2)
312 if textpage is None:
313 del tp
314 return rc
315
316
317def get_textpage_ocr(

Callers

nothing calls this directly

Calls 2

extractSelectionMethod · 0.80
get_textpageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…