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 isinstance(a_obj, NullObject):
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
13 changes: 13 additions & 0 deletions tests/test_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pypdf
from pypdf import PdfReader, PdfWriter
from pypdf._crypt_providers import crypt_provider
from pypdf.generic import Destination, Fit

from . import get_data_from_url
Expand All @@ -15,6 +16,10 @@
PROJECT_ROOT = TESTS_ROOT.parent
RESOURCE_ROOT = PROJECT_ROOT / "resources"

USE_CRYPTOGRAPHY = crypt_provider[0] == "cryptography"
USE_PYCRYPTODOME = crypt_provider[0] == "pycryptodome"
HAS_AES = USE_CRYPTOGRAPHY or USE_PYCRYPTODOME

sys.path.append(str(PROJECT_ROOT))


Expand Down Expand Up @@ -399,6 +404,14 @@ 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")
m = PdfWriter()
m.append(BytesIO(data))


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