Skip to content

Commit

Permalink
BUG: Skip annotation destination being NullObject in PdfWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan6419846 committed Nov 23, 2024
1 parent a6dc19f commit eca3431
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3000,6 +3000,8 @@ def _insert_filtered_annotations(
outlist.append(self._add_object(anc))
else:
d = cast("DictionaryObject", ano["/A"])["/D"]
if isinstance(d, NullObject):
continue
if isinstance(d, str):
# it is a named dest
if str(d) in self.get_named_dest_root():
Expand Down
10 changes: 10 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,16 @@ def test_append_pdf_with_dest_without_page(caplog):
assert len(writer.named_destinations) == 3


@pytest.mark.enable_socket
def test_destination_is_nullobject():
"""Tests for #2958"""
url = "https://github.com/user-attachments/files/17822279/C0.00.-.COVER.SHEET.pdf"
name = "iss2958.pdf"
source_data = BytesIO(get_data_from_url(url, name=name))
writer = PdfWriter()
writer.append(source_data)


def test_stream_not_closed():
"""Tests for #2905"""
src = RESOURCE_ROOT / "pdflatex-outline.pdf"
Expand Down

0 comments on commit eca3431

Please sign in to comment.