Add maxPages option to PDFParserConfig to limit page processing#2803
Draft
jnioche wants to merge 2 commits intoapache:mainfrom
Draft
Add maxPages option to PDFParserConfig to limit page processing#2803jnioche wants to merge 2 commits intoapache:mainfrom
jnioche wants to merge 2 commits intoapache:mainfrom
Conversation
Adds a configurable maxPages field to PDFParserConfig (default -1, no limit). When set, AbstractPDF2XHTML.processPages() breaks out of the page loop early, avoiding all text extraction, font mapping, and content stream work for pages beyond the limit. Validated on a 738-page PDF: parsing 5 pages is 13x faster than a full parse.
Adds maxPages to the PDF parser full config example, which is included in docs/configuration/parsers/pdf-parser.adoc and validated by ConfigExamplesTest#testPdfParserFullConfig.
Contributor
|
Should we do page range instead? pageStart, pageEnd, with 1 index? That would allow iterating through in chunks. I'm ok with this as is. wdyt? |
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.
Summary
maxPagesfield toPDFParserConfig(default-1, no limit)AbstractPDF2XHTML.processPages()breaks out of the page loop early when the limit is reached, skipping all text extraction, font mapping, and content stream work for subsequent pagesIllegalArgumentExceptionotherwisePerformance
Benchmarked on a 738-page PDF: