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

page.get_text("blocks") not working with PyMuPDF version 1.24.0 #3300

Closed
3051360 opened this issue Mar 23, 2024 · 3 comments
Closed

page.get_text("blocks") not working with PyMuPDF version 1.24.0 #3300

3051360 opened this issue Mar 23, 2024 · 3 comments
Labels
not a bug not a bug / user error / unable to reproduce

Comments

@3051360
Copy link

3051360 commented Mar 23, 2024

Description of the bug

page.get_text("blocks") has stopped working with the latest PyMuPDF version.

How to reproduce the bug

Below is a simple code snippet:

input_file = "my_pdf.pdf"
doc = fitz.open(input_file)

for page_no, page in enumerate(doc):
    print(page.get_text("blocks"))

With PyMuPDF version 1.22.2 the code prints:

[(0.0, 0.0, 273.6000061035156, 728.1599731445312, '<image: ICCBased(RGB,GIMP built-in sRGB), width: 1140, height: 3034, bpc: 8>', 0, 1)]

With PyMuPDF version 1.24.0 the code is not able to get anything.

PyMuPDF version

1.24.0

Operating system

MacOS

Python version

3.12

@JorjMcKie
Copy link
Collaborator

We cannot accept a bug report without a reproducing file.

@JorjMcKie
Copy link
Collaborator

JorjMcKie commented Mar 24, 2024

Please consult the documentation on text extraction flags and include TEXT_PRESERVE_IMAGES or use TEXTFLAGS_DICT as your flags value.

@JorjMcKie JorjMcKie added not a bug not a bug / user error / unable to reproduce and removed example required Waiting for information labels Mar 24, 2024
@3051360
Copy link
Author

3051360 commented Mar 24, 2024

Thank you for your response. I see that we now have to necessarily use this flag for documents containing images.

Earlier, with version 1.22.2 the flag was not required explicitly,

Screenshot 2024-03-24 at 5 13 29 PM

With version 1.24.0, the same code block does extract the image information by default,

image

But it does when the flag is supplied,

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug not a bug / user error / unable to reproduce
Projects
None yet
Development

No branches or pull requests

2 participants