Skip to content

Commit

Permalink
BUG: Accept XYZ destination with zoom missing (default to zoom=0.0) (#…
Browse files Browse the repository at this point in the history
…1844)

Closes #1832
  • Loading branch information
pubpub-zz authored May 18, 2023
1 parent 6fe1c30 commit c5dc49a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pypdf/generic/_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,8 @@ def __init__(

# from table 8.2 of the PDF 1.7 reference.
if typ == "/XYZ":
if len(args) < 3: # zoom is missing
args.append(NumberObject(0.0))
(
self[NameObject(TA.LEFT)],
self[NameObject(TA.TOP)],
Expand Down
12 changes: 12 additions & 0 deletions tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,3 +1156,15 @@ def test_iss1615_1673():
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name)))
writer = PdfWriter()
writer.clone_document_from_reader(reader)


@pytest.mark.enable_socket()
def test_destination_withoutzoom():
"""Cf issue #1832"""
url = (
"https://raw.githubusercontent.com/xrkk/tmpppppp/main/"
"2021%20----%20book%20-%20Security%20of%20biquitous%20Computing%20Systems.pdf"
)
name = "2021_book_security.pdf"
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name)))
reader.outline

0 comments on commit c5dc49a

Please sign in to comment.