Skip to content

Commit

Permalink
Adding test_watermarking_speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Cimon Lucas (LCM) committed Aug 20, 2023
1 parent 2b0b040 commit 4a0be88
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4a0be88

Please sign in to comment.