Fix PDF OCR import by switching to the PDFBox 3 Loader API#16
Open
Mercurlc wants to merge 2 commits into
Open
Conversation
Refactor PDF rendering to use Loader for loading PDF documents.
Member
|
Note that this change would make impossible to install this extension in anything older than XWiki 17.10.1, while it's currently documented as supporting XWiki 8.4+. I guess the cleanest would imply upgrading the parent version to 17.10 (which is based on 17.10.2) and, given the size of the jump, probably release a 2.0.0 version of the extension. If someone really need a for XWiki < 17.10, it's always possible to create a 1.x branch and continue release 1.1.x bugfix versions. WDYT @aubincleme ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Importing a PDF through the Tesseract OCR wizard fails at runtime with
NoSuchMethodErroronPDDocument.load(...).The current implementation in
PDFToImageRendererstill uses the PDFBox 2 API, while the runtime uses PDFBox 3, wherePDDocument.load(...)was removed.Root cause
application-ocr-tesseract-filteruses the old PDF loading API:PDDocument.load(...)In PDFBox 3 this API was removed and replaced with:
org.apache.pdfbox.Loader.loadPDF(...)This causes PDF OCR import to fail before the OCR step starts.
Fix
This PR updates the PDF rendering code in
PDFToImageRendererto use the PDFBox 3 Loader API.Changes included:
PDDocument.load(...)withLoader.loadPDF(...)pdfboxdependency inapplication-ocr-tesseract-filtercommons-loggingto satisfy XWiki dependency rulesValidation
Tested on a local XWiki Docker setup with the Tesseract OCR Application installed.
Result:
NoSuchMethodErrorno longer occursNotes
This change is limited to the PDF loading/rendering path in the Tesseract filter module.