Repository navigation
Fix create word crash between articles - #567
Closed
valerybokov wants to merge 2 commits into
Closed
valerybokov wants to merge 2 commits into
valerybokov wants to merge 2 commits into
Conversation
…rticle starts on the same line as the previous one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Nov 17, 2026
…loses #567 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/3.0@1940394 13f79535-47bb-0310-9956-ffa450edef68
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
PDFTextStripper.getText()throws anIndexOutOfBoundsExceptionwith default settings when a page hasarticle beads and a new article starts on the same baseline as the previous one, e.g. two beads side by side:
Cause
lastPositioninwritePage()carries over from one article to the next, but thelinebuffer is new foreach article. When the first glyph of the next article overlaps the last line of the previous one and is far
enough to the right, a word separator is added to the still-empty line.
normalizeAdd()then callscreateWord("", []), and since PDFBOX-6281 (f4dbe77)createWord()callswordPositions.get(0)unconditionally.
Fix
createWord()checksisFromActualText()only whenwordPositionsisn't empty. An empty word isnormalized as before, so the output matches the behavior before PDFBOX-6281:
LEFT RIGHT, not an exception(and not
LEFTRIGHT). TherequireNonNullcheck is removed: it could never report its message, becauseget(0)throws first.Test
TestTextStripper#testArticlesOnSameLinebuilds a page with two thread beads side by side, one word in each,and expects
"LEFT RIGHT\n". It fails with the exception above without the fix.TestTextStripper,BidiTestandPDFTextStripperByAreaTestpass.Per https://www.apache.org/legal/generative-tooling.html: portions of this PR were
produced with assistance from Claude Code (Anthropic), based on a bug was described in Apache PDFBOX Issue Tracker.
I've reviewed the generated code and confirm to the best of my knowledge that the output does not include any
third-party copyrighted material and is compatible with the Apache License 2.0.