Skip to content

Commit 9078cd9

Browse files
tests/test_insertpdf.py: test_4958(): new, reproducer for #4958.
1 parent 1a6787d commit 9078cd9

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/test_insertpdf.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,35 @@ def test_4571():
332332
else:
333333
# Incorrect.
334334
assert b'<</Type/Pages/Count 6/Kids[4 0 R 6 0 R 12 0 R 4 0 R 6 0 R 12 0 R]>>' in content
335-
335+
336+
337+
def test_4958():
338+
print()
339+
with pymupdf.Document() as document_orig, pymupdf.Document() as document_copy:
340+
document_orig.new_page()
341+
document_orig[0].set_rotation(90)
342+
document_orig[0].insert_link(
343+
{
344+
'kind': 2,
345+
'from': pymupdf.Rect(10, 20, 40, 60),
346+
'uri': 'https://example.org'
347+
}
348+
)
349+
350+
document_copy.insert_pdf(document_orig, links=True)
351+
352+
path_orig = os.path.normpath(f'{__file__}/../../tests/test_4958_out_orig.pdf')
353+
path_copy = os.path.normpath(f'{__file__}/../../tests/test_4958_out_copy.pdf')
354+
355+
document_orig.save(path_orig)
356+
document_copy.save(path_copy)
357+
358+
print(f'Have created {path_orig=}')
359+
print(f'Have created {path_copy=}')
360+
361+
from_rects_orig = [l['from'] for l in document_orig[0].get_links()]
362+
from_rects_copy = [l['from'] for l in document_copy[0].get_links()]
363+
364+
print(f'test_4958(): orig: {from_rects_orig}')
365+
print(f'test_4958(): copy: {from_rects_copy}')
366+
assert from_rects_orig == from_rects_copy

0 commit comments

Comments
 (0)