comparison tests/test_annots.py @ 41:71bcc18e306f

MERGE: New upstream PyMuPDF v1.26.5 including MuPDF v1.26.10 BUGS: Needs some additional changes yet. Not yet tested.
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 11 Oct 2025 15:24:40 +0200
parents a6bc019ac0b2
children
comparison
equal deleted inserted replaced
38:8934ac156ef5 41:71bcc18e306f
234 # restore this before returning (this is checked by conftest.py). 234 # restore this before returning (this is checked by conftest.py).
235 annot_stem = pymupdf.JM_annot_id_stem 235 annot_stem = pymupdf.JM_annot_id_stem
236 pymupdf.TOOLS.set_annot_stem('jorj') 236 pymupdf.TOOLS.set_annot_stem('jorj')
237 try: 237 try:
238 path_in = os.path.abspath( f'{__file__}/../resources/symbol-list.pdf') 238 path_in = os.path.abspath( f'{__file__}/../resources/symbol-list.pdf')
239 path_expected = os.path.abspath( f'{__file__}/../../tests/resources/test_1645_expected.pdf') 239 if pymupdf.mupdf_version_tuple >= (1, 27):
240 path_expected = os.path.abspath( f'{__file__}/../../tests/resources/test_1645_expected-after-1.27.0.pdf')
241 else:
242 path_expected = os.path.abspath( f'{__file__}/../../tests/resources/test_1645_expected.pdf')
240 path_out = os.path.abspath( f'{__file__}/../test_1645_out.pdf') 243 path_out = os.path.abspath( f'{__file__}/../test_1645_out.pdf')
241 doc = pymupdf.open(path_in) 244 doc = pymupdf.open(path_in)
242 page = doc[0] 245 page = doc[0]
243 page_bounds = page.bound() 246 page_bounds = page.bound()
244 annot_loc = pymupdf.Rect(page_bounds.x0, page_bounds.y0, page_bounds.x0 + 75, page_bounds.y0 + 15) 247 annot_loc = pymupdf.Rect(page_bounds.x0, page_bounds.y0, page_bounds.x0 + 75, page_bounds.y0 + 15)
252 fill_color=pymupdf.utils.getColor("FIREBRICK1"), 255 fill_color=pymupdf.utils.getColor("FIREBRICK1"),
253 rotate=page.rotation, 256 rotate=page.rotation,
254 ) 257 )
255 doc.save(path_out, garbage=1, deflate=True, no_new_id=True) 258 doc.save(path_out, garbage=1, deflate=True, no_new_id=True)
256 print(f'Have created {path_out}. comparing with {path_expected}.') 259 print(f'Have created {path_out}. comparing with {path_expected}.')
257 with open( path_out, 'rb') as f: 260 with pymupdf.open(path_expected) as doc_expected, pymupdf.open(path_out) as doc_out:
258 out = f.read() 261 rms = gentle_compare.pixmaps_rms(
259 with open( path_expected, 'rb') as f: 262 doc_expected[0].get_pixmap(),
260 expected = f.read() 263 doc_out[0].get_pixmap(),
261 assert out == expected, f'Files differ: {path_out} {path_expected}' 264 )
265 print(f'test_1645: {rms=}')
266 assert rms < 0.1, f'Pixmaps differ: {path_expected=} {path_out=}'
262 finally: 267 finally:
263 # Restore annot_stem. 268 # Restore annot_stem.
264 pymupdf.TOOLS.set_annot_stem(annot_stem) 269 pymupdf.TOOLS.set_annot_stem(annot_stem)
265 270
266 def test_1824(): 271 def test_1824():