Skip to content

Commit

Permalink
ROB: Accept XYZ with no arguments (#2178)
Browse files Browse the repository at this point in the history
Closes #2166
  • Loading branch information
pubpub-zz authored Sep 10, 2023
1 parent a1cfb21 commit ded1b0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pypdf/generic/_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,9 @@ def __init__(
self[NameObject("/Type")] = typ

# from table 8.2 of the PDF 1.7 reference.
if typ == "/XYZ":
if len(args) == 0:
pass
elif typ == "/XYZ":
if len(args) < 3: # zoom is missing
args.append(NumberObject(0.0))
(
Expand Down
3 changes: 3 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ def writer_operate(writer: PdfWriter) -> None:
writer.add_outline_item(
"The XYZ fit", 0, oi, (255, 0, 15), True, True, Fit.xyz(left=10, top=20, zoom=3)
)
writer.add_outline_item(
"The XYZ fit no args", 0, oi, (255, 0, 15), True, True, Fit.xyz()
)
writer.add_outline_item(
"The FitH fit", 0, oi, (255, 0, 15), True, True, Fit.fit_horizontally(top=10)
)
Expand Down

0 comments on commit ded1b0b

Please sign in to comment.