-
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
These messages are generated by MuPDF during open. MuPDF does all it can to make a PDF accessible.
So you could do this: try:
fitz.TOOLS.reset_mupdf_warnings() # empty the message store
doc = fitz.open(filename)
if doc.is_repaired:
print(f"{filename} had to be repaired!")
print(fitz.TOOLS.mupdf_warnings()) # prints and empties the message store
except ...:
# hardcore error - no way to repair and open this document |
Beta Was this translation helpful? Give feedback.
-
You cannot fix them. MuPDF does that for you where possible. If not, you get an exception from the function / method you were using. If you have to do with corrupt PDFs you can also clean the whole file before your actual processing - e.g. by MuPDF's own cli |
Beta Was this translation helpful? Give feedback.
-
There is no such method, you probably mean |
Beta Was this translation helpful? Give feedback.
-
In general, if MuPDF could open a PDF (or any other of its supported documents plethora), this dos not mean the file is error-free - even when no_ errors occurred at open. |
Beta Was this translation helpful? Give feedback.
-
Aha! You should have mentioned that earlier! |
Beta Was this translation helpful? Give feedback.
-
Depending on what you really are talking about: |
Beta Was this translation helpful? Give feedback.
Aha! You should have mentioned that earlier!
You can use
if len(page.get_text("words")) < n
to confirm that a page contains at leastn
words.