PyMuPDF
PyMuPDF copied to clipboard
insert_pdf gives TypeError
Description of the bug
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "C:\Program Files\Python311\Lib\site-packages\pymupdf\__init__.py", line 4529, in insert_pdf
self._do_links(docsrc, from_page = from_page, to_page = to_page, start_at = sa)
File "C:\Program Files\Python311\Lib\site-packages\pymupdf\utils.py", line 1618, in do_links
annot_text = cre_annot(l, xref_dst, pno_src, ctm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\pymupdf\utils.py", line 1528, in cre_annot
annot = txt % (xref_dst[idx], p.x, p.y, lnk["zoom"], rect)
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for %: 'function' and 'tuple'
How to reproduce the bug
Example file: https://download.enova.pl/sprzedaz/przewodniki/Procedura_zmiany_opiekuna_systemu_enova365.pdf
>>> with fitz.open() as newdoc:
... with fitz.open('Procedura_zmiany_opiekuna_systemu_enova365.pdf') as doc:
... newdoc.insert_pdf(doc)
PyMuPDF version
1.24.3
Operating system
Windows
Python version
3.11
We've run into exactly the same issue:
txt: <function <lambda> at 0x7f63a3e1ade0>
lnk: {
file: "somepdf",
from: Rect(473.75, 754.2000122070312, 552.25, 765.25),
id: "",
kind: 3,
xref: 350
}
Regression in bde7550154daad82ff7e346f033e78caf2784159.
Fixed by https://github.com/pymupdf/PyMuPDF/commit/2067826105c58c68942839aed95ae4e7909ee341.
Thanks. Dzięki.