You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not all errors require raising an exception. On the contrary, MuPDF strives to keep processing by falling back to whatever repair mechanisms.
You can suppress the display of these messages by setting a global parameter via pymupdf.TOOLS.mupdf_display_errors(False).
In any case, you can extract the error and warning messages (all collected in the same pymupdf string variable) via pymupdf.TOOLS.mupdf_warnings(reset=True). Each call with True empties that variable.
In your case you already today could do this
importpymupdfpymupdf.TOOLS.mupdf_display_errors(False)
# then, at any desired spot (e.g. pixmap creation) do this:pix=page.get_pixmap()
msg=pymupdf.TOOLS.mupdf_warnings(reset=True)
if"error"inmsg:
raiseRuntimeError(msg)
I am very much against an implementation as you indicated it. How many dozens or hundreds of methods would we have to change?
A focused implementation like indicated above serves the same purpose.
Is your feature request related to a problem? Please describe.
I'd like to implement a functionality which processes multiple PDF files one by one.
Some PDFs are "valid" while some of the PDF files are corrupted, in which case they should be ignored.
In my case, reading corrupted PDF files make
pymupdf
prints out a list of errors, instead of raising them.For instance, the following code
gives
Describe the solution you'd like
Arguable, raising the errors makes handling them easier. So I would like the following:
Perhaps via a configurable keyword argument
Describe alternatives you've considered
Are there several options for how your request could be met?
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: