Skip to content
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ history and [GitHub's 'Contributors' feature](https://github.com/py-pdf/pypdf/gr
* [Mérino, Antoine](https://github.com/Merinorus)
* [Murphy, Kevin](https://github.com/kmurphy4)
* [nalin-udhaar](https://github.com/nalin-udhaar)
* [Noah-Houghton](https://github.com/Noah-Houghton) | [LinkedIn](https://www.linkedin.com/in/noah-h-554992a0/)
* [Paramonov, Alexey](https://github.com/alexey-v-paramonov)
* [Paternault, Louis](https://framagit.org/spalax)
* [Perrensen, Olsen](https://github.com/olsonperrensen)
Expand Down
5 changes: 4 additions & 1 deletion pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3003,7 +3003,10 @@ def add_filtered_articles(
for p in pages.values():
pp = p.original_page
for a in pp.get("/B", ()):
thr = a.get_object().get("/T")
a_obj = a.get_object()
if is_null_or_none(a_obj):
continue
thr = a_obj.get("/T")
if thr is None:
continue
thr = thr.get_object()
Expand Down
2 changes: 2 additions & 0 deletions tests/example_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,5 @@
url: https://github.com/user-attachments/files/21578875/layout-parser-paper-with-empty-pages.pdf
- local_filename: issue-3429.pdf
url: https://github.com/user-attachments/files/21711469/bomb.pdf
- local_filename: issue-3508.pdf
url: https://github.com/user-attachments/files/23211824/repair-manual-thermo-230-300-350-2012-en.pdf
10 changes: 10 additions & 0 deletions tests/test_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pypdf.generic import Destination, Fit

from . import get_data_from_url
from .test_encryption import HAS_AES

TESTS_ROOT = Path(__file__).parent.resolve()
PROJECT_ROOT = TESTS_ROOT.parent
Expand Down Expand Up @@ -399,6 +400,15 @@ def test_articles_with_writer(caplog):
assert r.threads[0].get_object()["/F"]["/P"] == r.pages[0]


@pytest.mark.skipif(not HAS_AES, reason="No AES implementation")
@pytest.mark.enable_socket
def test_null_articles_with_writer():
data = get_data_from_url(name="issue-3508.pdf")
merger = PdfWriter()
merger.append(BytesIO(data))
assert len(merger.pages) == 98


def test_get_reference():
writer = PdfWriter(RESOURCE_ROOT / "crazyones.pdf")
assert writer.get_reference(writer.pages[0]) == writer.pages[0].indirect_reference
Expand Down
Loading