Skip to content

Commit c5dc49a

Browse files
authored
BUG: Accept XYZ destination with zoom missing (default to zoom=0.0) (#1844)
Closes #1832
1 parent 6fe1c30 commit c5dc49a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pypdf/generic/_data_structures.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,8 @@ def __init__(
13631363

13641364
# from table 8.2 of the PDF 1.7 reference.
13651365
if typ == "/XYZ":
1366+
if len(args) < 3: # zoom is missing
1367+
args.append(NumberObject(0.0))
13661368
(
13671369
self[NameObject(TA.LEFT)],
13681370
self[NameObject(TA.TOP)],

tests/test_generic.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,3 +1156,15 @@ def test_iss1615_1673():
11561156
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name)))
11571157
writer = PdfWriter()
11581158
writer.clone_document_from_reader(reader)
1159+
1160+
1161+
@pytest.mark.enable_socket()
1162+
def test_destination_withoutzoom():
1163+
"""Cf issue #1832"""
1164+
url = (
1165+
"https://raw.githubusercontent.com/xrkk/tmpppppp/main/"
1166+
"2021%20----%20book%20-%20Security%20of%20biquitous%20Computing%20Systems.pdf"
1167+
)
1168+
name = "2021_book_security.pdf"
1169+
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name)))
1170+
reader.outline

0 commit comments

Comments
 (0)