Skip to content

Commit

Permalink
ROB: XYZ destination to cope with missing left and top param
Browse files Browse the repository at this point in the history
closes #2236
  • Loading branch information
pubpub-zz committed Oct 3, 2023
1 parent 30db3ef commit 73a3134
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pypdf/generic/_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,10 @@ def __init__(
if len(args) == 0:
pass
elif typ == "/XYZ":
if len(args) < 1: # left is missing : should never occur
args.append(NumberObject(0.0))
if len(args) < 2: # top is missing
args.append(NumberObject(0.0))
if len(args) < 3: # zoom is missing
args.append(NumberObject(0.0))
(
Expand Down
9 changes: 9 additions & 0 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,3 +1454,12 @@ def test_issue_140():
b = get_data_from_url(url, name=name)
reader = PdfReader(BytesIO(b))
assert len(reader.pages) == 54


@pytest.mark.enable_socket()
def test_xyz_with_missing_param():
"""Cf #2236"""
url = "https://github.com/py-pdf/pypdf/files/12795356/tt1.pdf"
name = "issue2236.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
reader.outline

0 comments on commit 73a3134

Please sign in to comment.