KeyError in getLinkDict during PDF merge (original) (raw)

Please provide all mandatory information!

Describe the bug (mandatory)

With the rebased version, we are experiencing KeyError with PDFs that have links of type LINK_NAMED but no "to" field

To Reproduce (mandatory)

import fitz_new as fitz

def merge_pdf(content: bytes, coverpage: bytes): with fitz.Document(stream=coverpage, filetype="pdf") as coverpage_pdf, fitz.Document( stream=content, filetype="pdf" ) as content_pdf: coverpage_pdf.insert_pdf(content_pdf) doc = coverpage_pdf.write() return doc

def reproduce(): with open(f"content.pdf", "rb") as content_pdf, open(f"content.pdf", "rb") as coverpage_pdf: content = content_pdf.read() coverpage = coverpage_pdf.read() merge_pdf(content, coverpage)

reproduce()

content.pdf

Expected behavior (optional)

I expect the the merge to succeed (it does in the standard version)

Screenshots (optional)

Not applicable

Your configuration (mandatory)