OCRmyPDF: [3rdparty]: paperless-ngx AttributeError: 'PdfInfo' object has no attribute '_pages'
Simple sanity checks
- This is an issue with an app that uses OCRmyPDF for OCR
- I am using a recent version of the third party app
- I will include a file that reproduces the issuse
Third party app name and version
paperless-ngx 2.14.7
Describe the bug
[2025-02-20 23:51:47,676] [DEBUG] [paperless.parsing.tesseract] Calling OCRmyPDF with args: {'input_file': PosixPath('/tmp/paperless/paperless-ngx79qbunrp/DevisPellegrin_1_Plantation-1.pdf'), 'output_file': PosixPath('/tmp/paperless/paperless-2zyv5sx4/archive.pdf'), 'use_threads': True, 'jobs': 2, 'language': 'fra', 'output_type': 'pdfa', 'progress_bar': False, 'color_conversion_strategy': 'RGB', 'redo_ocr': True, 'clean': True, 'rotate_pages': True, 'rotate_pages_threshold': 12.0, 'sidecar': PosixPath('/tmp/paperless/paperless-2zyv5sx4/sidecar.txt')}
[2025-02-20 23:51:47,816] [DEBUG] [paperless.parsing.tesseract] Deleting directory /tmp/paperless/paperless-2zyv5sx4
[2025-02-20 23:51:47,819] [ERROR] [paperless.consumer] Error occurred while consuming document DevisPellegrin_1_Plantation-1.pdf: AttributeError: 'PdfInfo' object has no attribute '_pages'
DevisPellegrin_1_Plantation.pdf
Steps to reproduce
1. Import attached file into Paperless-ngx
2. Trigger OCR
3. Check log file
Files
I have added the pdf file above
OCRmyPDF version
ocrmypdf --version 16.8.0
Relevant log output
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 19
With the latest version 2.16.2 same problem. After switching from redo to skip the errors go away so still not fixed the problem.
Some PDF may be damaged or non conforming I don’t know. Some consumed PDF files from mails have this issue which was really annoying to manually convert them which was printing them into a new PDF which solved it.
What I did was adding a preconsume script like this and let ghostscript reprint a PDF file:
Yes apologies for not confirming, I can reproduce as above
Yes, default is mode ‘skip’, if ocr’ed text is available in the PDF, the ocr step is not done. When I activated mode ‘redo’ the error appeared also in the demo instance.
Hi, it is related to the OCR mode in paperless and after forcing ocrmypdf to do the OCR (and not skip), I could reproduce the error as @remisharrock described (https://github.com/paperless-ngx/paperless-ngx/issues/9179#issuecomment-2691514952).