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

fix: Correctly patch pdfminer to avoid unnecessarily and unsuccessfully repairing PDFs with long content streams, causing needless and endless OCR #3822

Merged
merged 10 commits into from
Jan 24, 2025

Conversation

dhdaines
Copy link
Contributor

@dhdaines dhdaines commented Dec 12, 2024

Fixes: #3815

Verified on my very large documents that it doesn't unnecessarily and unsuccessfully "repair" them.

You may or may not wish to keep the version check in patch_psparser. Since you're pinning the version of pdfminer.six and since it isn't guaranteed that the bug in question will be fixed in the next pdfminer.six release (but it is rather serious, so I should hope so), then perhaps you just want to unconditionally patch it. it seems like pinning of versions is only operative when running from Docker (good!) so never mind! Keep that version check!

Also corrected an import so that if you do feel like using a newer version of pdfminer.six, it won't break on you.

@dhdaines dhdaines changed the title Fix the fix to pdfminer Correctly patch pdfminer to avoid unnecessarily and unsuccessfully repairing PDFs with long content streams, causing needless and endless OCR Dec 12, 2024
@dhdaines dhdaines changed the title Correctly patch pdfminer to avoid unnecessarily and unsuccessfully repairing PDFs with long content streams, causing needless and endless OCR fix: Correctly patch pdfminer to avoid unnecessarily and unsuccessfully repairing PDFs with long content streams, causing needless and endless OCR Dec 17, 2024
@PhorstenkampFuzzy
Copy link

Any update on this?

@qued qued self-requested a review January 24, 2025 16:23
Copy link
Contributor

@qued qued left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Here's what I checked:

  • Ran the tests with this branch to verify that invalid-pdf-structure-pdfminer-entire-doc.pdf is being repaired while invalid-pdf-structure-pdfminer-one-page.pdf is not.
  • Processed invalid-pdf-structure-pdfminer-one-page.pdf (unrepaired) using fast strategy with the new code and looked over the results to ensure the doc is being processed properly.
  • Processed invalid-pdf-structure-pdfminer-entire-doc.pdf (repaired) using fast strategy with the new code and looked over the results to ensure the doc is being processed properly.
  • Processed linked doc here with this branch and main branch to verify that the doc fails before the fix and succeeds afterwards.

@qued
Copy link
Contributor

qued commented Jan 24, 2025

@dhdaines Thanks for fixing this!

@qued qued merged commit 9e5ff22 into Unstructured-IO:main Jan 24, 2025
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug/Unstructured unnecessarily "repairs" then falls back to OCR on extremely large documents
3 participants