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

Function JM_copy_rectangle

src/__init__.py:19054–19074  ·  view source on GitHub ↗
(page, area)

Source from the content-addressed store, hash-verified

19052
19053
19054def JM_copy_rectangle(page, area):
19055 need_new_line = 0
19056 buffer = io.StringIO()
19057 for block in page:
19058 if block.m_internal.type != mupdf.FZ_STEXT_BLOCK_TEXT:
19059 continue
19060 for line in block:
19061 line_had_text = 0
19062 for ch in line:
19063 r = JM_char_bbox(line, ch)
19064 if JM_rects_overlap(area, r):
19065 line_had_text = 1
19066 if need_new_line:
19067 buffer.write("\n")
19068 need_new_line = 0
19069 buffer.write(make_escape(ch.m_internal.c))
19070 if line_had_text:
19071 need_new_line = 1
19072
19073 s = buffer.getvalue() # take over the data
19074 return s
19075
19076
19077def JM_convert_to_pdf(doc, fp, tp, rotate):

Callers 1

extractTextboxMethod · 0.85

Calls 4

JM_char_bboxFunction · 0.85
JM_rects_overlapFunction · 0.85
make_escapeFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…