Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NumberObject' object has no attribute 'indirect_reference' #1898

Closed
jflalande opened this issue Jun 20, 2023 · 2 comments · Fixed by #1858
Closed

AttributeError: 'NumberObject' object has no attribute 'indirect_reference' #1898

jflalande opened this issue Jun 20, 2023 · 2 comments · Fixed by #1858

Comments

@jflalande
Copy link

An exception occurs when merging the joint pdf with itself:

  File "/home/jf/.local/lib/python3.10/site-packages/pypdf/_writer.py", line 2863, in merge
    elif dest["/Page"].indirect_reference.idnum in srcpages:
AttributeError: 'NumberObject' object has no attribute 'indirect_reference'

Environment

Which environment were you using when you encountered the problem?

$ python3 -m platform
Linux-5.19.0-35-generic-x86_64-with-glibc2.35
$ python3 -c "import pypdf;print(pypdf.__version__)"
3.10.0

Code + PDF

This is a minimal, complete example that shows the issue:

from pypdf import PdfWriter

merger = PdfWriter()
for pdf in ["tmp.pdf", "tmp.pdf"]:
    merger.append(pdf)

merger.write("merged-pdf.pdf")
merger.close()

Share here the PDF file(s) that cause the issue. The smaller they are, the
better. Let us know if we may add them to our tests!

Traceback

This is the complete Traceback I see:

python3 test.py 
Traceback (most recent call last):
  File "/home/jf/CentraleSupelec/Mention_Cyber/syllabus/test.py", line 5, in <module>
    merger.append(pdf)
[tmp.pdf](https://github.com/py-pdf/pypdf/files/11799685/tmp.pdf)

  File "/home/jf/.local/lib/python3.10/site-packages/pypdf/_writer.py", line 2767, in append
    self.merge(
  File "/home/jf/.local/lib/python3.10/site-packages/pypdf/_utils.py", line 439, in wrapper
    return func(*args, **kwargs)
  File "/home/jf/.local/lib/python3.10/site-packages/pypdf/_writer.py", line 2863, in merge
    elif dest["/Page"].indirect_reference.idnum in srcpages:
AttributeError: 'NumberObject' object has no attribute 'indirect_reference'

tmp.pdf

@pubpub-zz
Copy link
Collaborator

solution in progress

@pubpub-zz
Copy link
Collaborator

actually the solution is in the pipe since a month.
@MartinThoma should merge it soon (he has already merged #1856 required and resolved conflicts)

MartinThoma pushed a commit that referenced this issue Jun 25, 2023
The issue was with named destination using numbers instead of indirect object to point pages. This is normally not expected.

Closes #471
Closes #1898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants