diff --git a/tests/test_writer.py b/tests/test_writer.py index 46c4912bd1..e71cf5b7f3 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -1536,6 +1536,27 @@ def test_watermark(): assert len(b.getvalue()) < 2.1 * 1024 * 1024 +@pytest.mark.enable_socket() +@pytest.mark.timeout(45) # this was > x2 slower before PR #2086 +def test_watermarking_speed(): + url = "https://github.com/py-pdf/pypdf/files/11985889/bg.pdf" + name = "bgwatermark.pdf" + reader = PdfReader(BytesIO(get_data_from_url(url, name=name))) + url = "https://arxiv.org/pdf/2201.00214.pdf" + name = "src_doc.pdf" + writer = PdfWriter(clone_from=BytesIO(get_data_from_url(url, name=name))) + for p in writer.pages: + p.merge_page(reader.pages[0], over=False) + + assert isinstance(p["/Contents"], ArrayObject) + assert isinstance(p["/Contents"][0], IndirectObject) + + b = BytesIO() + writer.write(b) + print(len(b.getvalue()) / 1024 / 1024) + assert len(b.getvalue()) < 2.5 * 1024 * 1024 + + @pytest.mark.enable_socket() def test_da_missing_in_annot(): url = "https://github.com/py-pdf/pypdf/files/12136285/Building.Division.Permit.Application.pdf"