-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Link in the new (3.14.0) annotation module returns an empty dict. #2058
Comments
@ymareth |
For version 3.13.0 this produces a link: from pypdf import PdfWriter
from pypdf.generic import AnnotationBuilder
writer = PdfWriter()
writer.add_blank_page(720, 720)
writer.write('test.pdf')
link_annotation = AnnotationBuilder.link(rect=(0, 00, 300, 300), target_page_index=1)
print(link_annotation)
writer.add_annotation(0, link_annotation)
writer.write('link1.pdf') Results in what looks like a healthy link definition:
For version 3.14.0 we have to change the code a bit to use the annotations module: import pypdf as pp
import pypdf.annotations as ppa
writer = pp.PdfWriter()
writer.add_blank_page(720, 720)
writer.write('test.pdf')
writer = pp.PdfWriter()
with open('test.pdf' , 'rb') as fh:
reader = pp.PypdfReader(fh)
writer.add_page(reader.pages[0])
link = ppa.Link(rect=(50, 100, 150, 200), targer_page_index=1)
print(link) Results in and empty dict.
|
Thank you for reporting the issue. I've adjusted the first code sample a bit and will have a look. |
Found the issue. Fix is on its way. |
The object was not updating itself, but a temporary variable in it Closes #2058
The object was not updating itself, but a temporary variable in it Closes #2058
Thank you for letting us know 🙏 The issue is fixed with |
If you want, I can add you as a contributor: https://pypdf.readthedocs.io/en/latest/meta/CONTRIBUTORS.html |
The new Link class in annotation returns an empty* dict and hence creates no link.
I took a look at the link class and can't see any calls to self.update (since the base class is dict) as I do in the other annotation classes.
I reverted back to pypdf.generic.AnnotationBuilder.add_link with the same call parameters and links are inserted as expected.
*possibly 'title' would get through via the kwargs into the super constructor.
Environment
Windows, Python 3.11, running version 3.14.0
The text was updated successfully, but these errors were encountered: