Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off print statements in utils.py #2345

Closed
Ulipenitz opened this issue Apr 15, 2023 · 5 comments
Closed

Turn off print statements in utils.py #2345

Ulipenitz opened this issue Apr 15, 2023 · 5 comments

Comments

@Ulipenitz
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Potentially add an issue reference.

When I run the insert_pdf() method on a pdf, I sometimes get hundreds of print statements like these:
print("cannot create /Annot for kind: " + str(l["kind"]))

Describe the solution you'd like
A clear and concise description of what you want to happen.

I want to be able to turn them off, so that my terminal is not overloaded.

Describe alternatives you've considered
Are there several options for how your request could be met?

Maybe logging could be used instead of print statements

Additional context
Add any other context or screenshots about the feature request here.

@JorjMcKie
Copy link
Collaborator

You can exclude annotations and / or links from being copied alongside their pages:

doc.insert_pdf(src, from_page=f, to_page=t, annots=False, links=False)

Then copying these objects will be suppressed and no messages will be issued. The default is copying these object types.
For me, a message informing about failing to do desired actions is worth reporting.
I can look whether it s possible to re-route the warnings to the MuPDF container, so they can be viewed via fitz.TOOLS.mupdf_warnings() as desired.

@JorjMcKie
Copy link
Collaborator

Again thinking about it:
These messages actually make no sense in any case, because they in essence simply say, that something went wrong without being able to mention the actual cause, not to speak of ways to fix it. So I will simply omit the messages I think.

JorjMcKie added a commit that referenced this issue Apr 17, 2023
Previously we displayed error messages (Python `print()`) if a link could not be replicated on the target page within method `doc.insert_pdf()`.

As the method has no way to provide more information on the problem's cause, and hence cannot provide information on how to fix the problems, the messages make no sense and will be omitted.
julian-smith-artifex-com pushed a commit to ArtifexSoftware/PyMuPDF-julian that referenced this issue Apr 18, 2023
Previously we displayed error messages (Python `print()`) if a link could not be replicated on the target page within method `doc.insert_pdf()`.

As the method has no way to provide more information on the problem's cause, and hence cannot provide information on how to fix the problems, the messages make no sense and will be omitted.
julian-smith-artifex-com pushed a commit that referenced this issue Apr 18, 2023
Previously we displayed error messages (Python `print()`) if a link could not be replicated on the target page within method `doc.insert_pdf()`.

As the method has no way to provide more information on the problem's cause, and hence cannot provide information on how to fix the problems, the messages make no sense and will be omitted.
@julian-smith-artifex-com
Copy link
Collaborator

Fixed in PyMuPDF-1.22.1.

@backnotprop
Copy link

How do we debug this? agree with @JorjMcKie

@backnotprop
Copy link

I cant suppress the logging with or without the annots=False, param.

julian-smith-artifex-com pushed a commit to ArtifexSoftware/PyMuPDF-julian that referenced this issue Nov 22, 2023
…intentionally reverted.

Previously we displayed error messages (Python `print()`) if a link could not
be replicated on the target page within method `doc.insert_pdf()`.

As the method has no way to provide more information on the problem's cause,
and hence cannot provide information on how to fix the problems, the messages
make no sense and will be omitted.
julian-smith-artifex-com pushed a commit that referenced this issue Nov 22, 2023
…onally reverted.

Previously we displayed error messages (Python `print()`) if a link could not
be replicated on the target page within method `doc.insert_pdf()`.

As the method has no way to provide more information on the problem's cause,
and hence cannot provide information on how to fix the problems, the messages
make no sense and will be omitted.
julian-smith-artifex-com pushed a commit to ArtifexSoftware/PyMuPDF-julian that referenced this issue Nov 23, 2023
…intentionally reverted.

Previously we displayed error messages (Python `print()`) if a link could not
be replicated on the target page within method `doc.insert_pdf()`.

As the method has no way to provide more information on the problem's cause,
and hence cannot provide information on how to fix the problems, the messages
make no sense and will be omitted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants