Open
Description
If I create a link with positional, it jumps to an unintended page.
Environment
$ python -m platform
Windows-10-10.0
$ python -c "import PyPDF2;print(PyPDF2.__version__)"
2.10.7
Code + PDF
I want to use the "fit" option, so I write it positional.
from PyPDF2 import PdfWriter, PdfReader
from PyPDF2.generic import RectangleObject
in_file = r"D:\xxxxxxxxxxx\in.pdf"
out_file = r"D:\xxxxxxxxxxx\out.pdf"
writer = PdfWriter()
reader = PdfReader(in_file)
for current_page in reader.pages:
writer.add_page(current_page)
writer.addLink(0, 1, [97, 758, 162, 768], [1, 1, 1], "/XYZ", 0, 0, 0) # <-- here
with open(out_file, "wb") as o:
writer.write(o)
Then when I click the link it jumps from page 1 to page "3".
When I open the link properties with Acrobat, the link destination is set to page "2", and after closing the properties with OK without updating anything, clicking the link again correctly jumps to page "2".
It's hard to open the properties of all created links and click OK, so please give me an idea how to solve it.
Traceback
This is the complete Traceback I see:
TODO