| 474 | |
| 475 | |
| 476 | def 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 | |
| 498 | def test_4245(): |