Skip to content

Commit a33e1d4

Browse files
committed
Update PyMuPDF to cope with warnings changes in 1.28.0.
Text extraction now only produces warnings about corrupt struct trees or layers, if the struct trees or layers are used.
1 parent 08fb32d commit a33e1d4

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

tests/test_2548.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def test_2548():
3232
# This checks that PyMuPDF 1.23.7 fixes this bug, and also that earlier
3333
# versions with updated MuPDF also fix the bug.
3434
rebased = hasattr(pymupdf, 'mupdf')
35-
if pymupdf.mupdf_version_tuple >= (1, 27):
35+
if pymupdf.mupdf_version_tuple >= (1, 28):
36+
expected = ''
37+
elif pymupdf.mupdf_version_tuple >= (1, 27):
3638
expected = 'format error: No common ancestor in structure tree\nstructure tree broken, assume tree is missing'
3739
expected = '\n'.join([expected] * 5)
3840
else:

tests/test_general.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,11 +911,17 @@ def test_bboxlog_2885():
911911

912912
bbl = page.get_bboxlog()
913913
wt = pymupdf.TOOLS.mupdf_warnings()
914-
assert wt == 'invalid marked content and clip nesting'
914+
if pymupdf.mupdf_version_tuple >= (1, 28):
915+
assert wt == ''
916+
else:
917+
assert wt == 'invalid marked content and clip nesting'
915918

916919
bbl = page.get_bboxlog(layers=True)
917920
wt = pymupdf.TOOLS.mupdf_warnings()
918-
assert wt == 'invalid marked content and clip nesting'
921+
if pymupdf.mupdf_version_tuple >= (1, 28):
922+
assert wt == ''
923+
else:
924+
assert wt == 'invalid marked content and clip nesting'
919925

920926
def test_3081():
921927
'''
@@ -1757,7 +1763,10 @@ def test_3569():
17571763
'</svg>\n'
17581764
)
17591765
wt = pymupdf.TOOLS.mupdf_warnings()
1760-
assert wt == 'unknown cid collection: PDFAUTOCAD-Indentity0\nnon-embedded font using identity encoding: ArialMT (mapping via )\ninvalid marked content and clip nesting'
1766+
if pymupdf.mupdf_version_tuple >= (1, 28):
1767+
assert wt == 'unknown cid collection: PDFAUTOCAD-Indentity0\nnon-embedded font using identity encoding: ArialMT (mapping via )'
1768+
else:
1769+
assert wt == 'unknown cid collection: PDFAUTOCAD-Indentity0\nnon-embedded font using identity encoding: ArialMT (mapping via )\ninvalid marked content and clip nesting'
17611770

17621771
def test_3450():
17631772
# This issue is a slow-down, so we just show time taken - it's not safe

tests/test_textextract.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ def get_all_page_from_pdf(document, last_page=None):
387387
assert texts1 == texts0
388388

389389
wt = pymupdf.TOOLS.mupdf_warnings()
390-
if pymupdf.mupdf_version_tuple >= (1, 27):
390+
if pymupdf.mupdf_version_tuple >= (1, 28):
391+
expected = ''
392+
assert wt == expected
393+
elif pymupdf.mupdf_version_tuple >= (1, 27):
391394
expected = 'format error: No common ancestor in structure tree\nstructure tree broken, assume tree is missing'
392395
expected = '\n'.join([expected] * 56)
393396
assert wt == expected

0 commit comments

Comments
 (0)