Repository navigation
PDFBOX-6338 Fix actual text state between pages - #571
Closed
valerybokov wants to merge 2 commits into
Closed
valerybokov wants to merge 2 commits into
valerybokov wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…losed on a page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Please create a JIRA ticket, this looks like a bug. |
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Nov 21, 2026
…kov; closes #571 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/2.0@1940615 13f79535-47bb-0310-9956-ffa450edef68
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Nov 21, 2026
…kov; closes #571 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/3.0@1940616 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
If a page has an
/ActualTextmarked-content sequence that isn't closed (aBDCwithout itsEMC),PDFTextStripperkeeps applying it to all following pages:Expected
Xandtwo, but the text of page 2 is lost: every glyph after the first one in an ActualTextsequence is replaced with an empty string. The state also survives into the next document if the same
stripper is reused, so a valid document can come out empty.
Cause
currentMarkedContents,actualText,actualTextMarkedContentandfirstActualTextPositionare onlychanged by the
BDC/BMC/EMCoperators, and nothing resets them between pages or inresetEngine().Fix
processPage()clears these fields before the page's content is processed. A marked-content sequencecan't span pages, so nothing valid is lost. Every page goes through
processPage(), so this also coversthe first page of the next document.
Test
TestTextStripper#testUnclosedActualTextextracts a two-page document whose first page leavesActualText(X)open (expectsX\ntwo\n), then a second document with the same stripper (expectsthree\n). It fails 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).
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.