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

Function test_4139

tests/test_textextract.py:476–495  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

474
475
476def test_4139():
477 path = os.path.normpath(f'{__file__}/../../tests/resources/test_4139.pdf')
478 flags = (0
479 | pymupdf.TEXT_PRESERVE_IMAGES
480 | pymupdf.TEXT_PRESERVE_WHITESPACE
481 | pymupdf.TEXT_USE_CID_FOR_UNKNOWN_UNICODE
482 )
483 with pymupdf.open(path) as document:
484 page = document[0]
485 dicts = page.get_text('dict', flags=flags, sort=True)
486 seen = set()
487 for b_ctr, b in enumerate(dicts['blocks']):
488 for l_ctr, l in enumerate(b.get('lines', [])):
489 for s_ctr, s in enumerate(l['spans']):
490 color = s.get('color')
491 if color is not None and color not in seen:
492 seen.add(color)
493 print(f"B{b_ctr}.L{l_ctr}.S{s_ctr}: {color=} {hex(color)=} {s=}")
494 assert color == 0, f'{s=}'
495 assert s['alpha'] == 255
496
497
498def test_4245():

Callers

nothing calls this directly

Calls 3

get_textMethod · 0.45
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…