-
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
pypdf creates invalid links with add_annotation since PyPDF2 2.9.0 #2443
Labels
is-bug
From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF
Comments
Thanks for the report. Do you want to submit a corresponding PR for it? |
MartinThoma
added
the
is-bug
From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF
label
Feb 6, 2024
rsinger417
added a commit
to rsinger417/pypdf
that referenced
this issue
Feb 8, 2024
passes an IndirectObject for the target page instead of an integer. passing an integer creates an invalid link. resolves py-pdf#2443 Issue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
is-bug
From a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF
Many years ago I used pypdf to create links for a book of maps for our storm sewer system. I had an index page that had links to all of the other pages and each page had links to the page with the maps to the North, South, East and West, and back to the index page. I could delete pages and all of the link remained good, that is the links would take me to the correct pages. This book had 550 pages in it, 449 links on the index page and a maximum 5 links per page. It worked great, when I needed to update pages I would just use Acrobat to replace the pages and after many years I forgot how I did it and all about pypdf. Now I had to make new pages and the book increased to 625 page with the pages being shuffled and I had to recreate all of the links all over again. I had to make 3590 links. I found pypdf again and managed to do it again, but this time when I delete pages the links to the adjacent page where broken.
I did some investigation with a smaller test file and found out that this bug was created with PyPDF2 version 2.9.0 with the introduction of add_annotation sub in _writer.py. The target_page_index was passed as an int where in the previous versions it was passed as an Indirectobject. I was able to correct the bug by add two lines of code and changing another line in PyPDF2 version 2.9.0.
I tried the fix in pypdf version 4.0.0 and it worked great. Problem solved.
Environment
Windows 10
Code add_annotation pypdf version 4.0.0 revised code
The text was updated successfully, but these errors were encountered: