I am trying to open a pdf file protected by password, looks like the pymupdf is unable to decrypt even with correct password.
Browser/Other PDF Reader Behaviour
- Able to open file with password
- Able to print and and save without password after opening it.
pymupdf Behaviour
> pdf_doc = pymupdf.open("/data/file.pdf")
> pdf_doc.needs_pass
1
> pdf_doc.permissions
0
> pdf_doc.is_encrypted
True
> pdf_doc.authenticate("password")
4
> pdf_doc.is_encrypted
False
> pdf_doc[0].get_text()
MuPDF error: library error: zlib error: incorrect header check
'' (empty string and warning above)
> pdf_doc.save("/data/file_unlocked.pdf") -> Empty 5 pages file, number of pages is same as original file
When I open the file with password in other pdf application and then print and save pdf without password then MuPDF is able to read the file and able to get me the text using get_text