feat(text): extract text from form XObjects#85
Open
l-ajeti wants to merge 3 commits into
Open
Conversation
Text extraction only processed a page's top-level content stream, so pages that draw all their text inside form XObjects (common in tax/accounting and reporting PDFs, e.g. IRS Form 8879-PE) extracted as empty strings — indistinguishable from a scanned image. TextExtractor now handles the `Do` operator: on a /Subtype /Form XObject it recurses into the form's content stream using the form's own /Resources, with the form's /Matrix concatenated onto the CTM. Image XObjects resolve to null and are skipped. - Add ResourceResolver/FormXObject abstraction (fonts + XObjects), scoped per content stream; PDFPage builds and memoizes resolvers by Resources-dict identity (matching _resourceCache/_annotationCache). - TextState gains captureState/restoreState that snapshot the full state and graphics-stack depth, so unbalanced q/Q inside a form cannot corrupt the rest of the page (lenient malformed-PDF handling). - Guard nested/cyclic forms with a depth cap. Tests: unit coverage for nested extraction, form-scoped fonts, state isolation, /Matrix application, cycle safety, and back-compat; an integration fixture (form-xobject-text.pdf). The rtl-placed-text fixture is regenerated to drop a redundant duplicate text layer that conflicted with now-correct form recursion; its RTL content stream (the test subject) is preserved byte-for-byte. Plan: .agents/plans/046-form-xobject-text-extraction.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
@l-ajeti is attempting to deploy a commit to the mythie's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Text extraction only processed a page's top-level content stream, so pages that draw all their text inside form XObjects (common in tax/accounting and reporting PDFs, e.g. IRS Form 8879-PE) extracted as empty strings — indistinguishable from a scanned image.
TextExtractor now handles the
Dooperator: on a /Subtype /Form XObject it recurses into the form's content stream using the form's own /Resources, with the form's /Matrix concatenated onto the CTM. Image XObjects resolve to null and are skipped.Tests: unit coverage for nested extraction, form-scoped fonts, state isolation, /Matrix application, cycle safety, and back-compat; an integration fixture (form-xobject-text.pdf). The rtl-placed-text fixture is regenerated to drop a redundant duplicate text layer that conflicted with now-correct form recursion; its RTL content stream (the test subject) is preserved byte-for-byte.
Plan: .agents/plans/046-form-xobject-text-extraction.md