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

Function JM_make_textpage_dict

src/__init__.py:20726–20756  ·  view source on GitHub ↗
(tp, page_dict, raw)

Source from the content-addressed store, hash-verified

20724
20725
20726def JM_make_textpage_dict(tp, page_dict, raw):
20727 if 1 or g_use_extra:
20728 return extra.JM_make_textpage_dict(tp.m_internal, page_dict, raw)
20729 text_buffer = mupdf.fz_new_buffer(128)
20730 block_list = []
20731 tp_rect = mupdf.FzRect(tp.m_internal.mediabox)
20732 block_n = -1
20733 #log( 'JM_make_textpage_dict {=tp}')
20734 for block in tp:
20735 block_n += 1
20736 if (not mupdf.fz_contains_rect(tp_rect, mupdf.FzRect(block.m_internal.bbox))
20737 and not mupdf.fz_is_infinite_rect(tp_rect)
20738 and block.m_internal.type == mupdf.FZ_STEXT_BLOCK_IMAGE
20739 ):
20740 continue
20741 if (not mupdf.fz_is_infinite_rect(tp_rect)
20742 and mupdf.fz_is_empty_rect(mupdf.fz_intersect_rect(tp_rect, mupdf.FzRect(block.m_internal.bbox)))
20743 ):
20744 continue
20745
20746 block_dict = dict()
20747 block_dict[dictkey_number] = block_n
20748 block_dict[dictkey_type] = block.m_internal.type
20749 if block.m_internal.type == mupdf.FZ_STEXT_BLOCK_IMAGE:
20750 block_dict[dictkey_bbox] = JM_py_from_rect(block.m_internal.bbox)
20751 JM_make_image_block(block, block_dict)
20752 else:
20753 JM_make_text_block(block, block_dict, raw, text_buffer, tp_rect)
20754
20755 block_list.append(block_dict)
20756 page_dict[dictkey_blocks] = block_list
20757
20758
20759def JM_matrix_from_py(m):

Callers 1

_getNewBlockListMethod · 0.85

Calls 4

JM_py_from_rectFunction · 0.85
JM_make_image_blockFunction · 0.85
JM_make_text_blockFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…