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

Function JM_new_buffer_from_stext_page

src/__init__.py:20943–20961  ·  view source on GitHub ↗

make a buffer from an stext_page's text

(page)

Source from the content-addressed store, hash-verified

20941
20942
20943def JM_new_buffer_from_stext_page(page):
20944 '''
20945 make a buffer from an stext_page's text
20946 '''
20947 assert isinstance(page, mupdf.FzStextPage)
20948 rect = mupdf.FzRect(page.m_internal.mediabox)
20949 buf = mupdf.fz_new_buffer(256)
20950 for block in page:
20951 if block.m_internal.type == mupdf.FZ_STEXT_BLOCK_TEXT:
20952 for line in block:
20953 for ch in line:
20954 if (not JM_rects_overlap(rect, JM_char_bbox(line, ch))
20955 and not mupdf.fz_is_infinite_rect(rect)
20956 ):
20957 continue
20958 mupdf.fz_append_rune(buf, ch.m_internal.c)
20959 mupdf.fz_append_byte(buf, ord('\n'))
20960 mupdf.fz_append_byte(buf, ord('\n'))
20961 return buf
20962
20963
20964def JM_new_javascript(pdf, value):

Callers 1

JM_search_stext_pageFunction · 0.85

Calls 2

JM_rects_overlapFunction · 0.85
JM_char_bboxFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…