mupdf: Can't do incremental writes when changing encryption

Resolved it using lower version of PYmuPDF. pip install PyMuPDF==1.14.20


doc.save() uses encryption=PDF_ENCRYPT_NONE by default (see documentation here). Your document must have some type of encryption, which doc.save is attempting to remove (i.e. change to none).

Knowing this, the error is self explanatory: fitz cannot save incrementally and change the encryption.

You expressed no desire to change encryption in your question/code, so you can specify to keep it.

To do this, you can use:

 doc.save(doc.name, incremental=True, encryption=PDF_ENCRYPT_KEEP).

Or you can also use doc.saveIncr() as a convenience abbreviation (see here for docs).