I am writing below code to remove annotations from a pdf file and then save it to new pdf. However, I am getting RuntimeError: invalid key in dict. Below is the Code:
import fitz
import re
doc = fitz.open("test.pdf")
for i in range(doc.pageCount):
page = doc[i]
for annot in page.annots():
page.delete_annot(annot)
doc.save('test1.pdf')
Error: mupdf: invalid key in dict
RuntimeError: invalid key in dict