When using .to_markdown I get output messages to stdout which I cannot seem to suppress:
=== Document parser messages ===
Using Tesseract for OCR processing.
OCR on page.number=0/1.
I have tried many strategies with no luck… Is there some way to disable these messages??
Suppress all PyMuPDF/Tesseract messages entirely
os.environ[“PYMUPDF_MESSAGE”] = “”
os.environ[“PYMUPDF_MESSAGE”] = “path:pymupdf_logs.txt”
Disable logging for pymupdf/pymupdf4llm
logging.getLogger(“pymupdfllm”).setLevel(logging.CRITICAL + 1)
logging.getLogger(“pymupdf”).setLevel(logging.CRITICAL + 1)
logging.getLogger(“pypdf”).setLevel(logging.ERROR)
logging.getLogger(“fitz”).setLevel(logging.CRITICAL + 1)
logging.getLogger(“tesseract”).setLevel(logging.CRITICAL + 1)
Suppress MuPDF errors
fitz.TOOLS.mupdf_display_errors(False)
Suppress MuPDF error and warning messages
pymupdf.TOOLS.mupdf_display_errors(False)
pymupdf.TOOLS.mupdf_display_warnings(False)
Redirect stdout
with open(‘output.txt’, ‘w’) as f:
sys.stdout = f # Change the standard output to the file we created
print(“This message goes to the file”)