Repository navigation
Conversation
abgrad
force-pushed
the
actualtext-marked-content
branch
from
October 28, 2026 13:38
76d4e6b to
9e0e078
Compare
|
We need this change too. We use /ActualText to make pdf.js text match pdftotext for small-caps fonts that decode to the wrong case. Our version had two more test cases: a UTF-16BE string ( gives "é") and a non-string value (no actualText). Consider adding these. See #22473 |
abgrad
force-pushed
the
actualtext-marked-content
branch
from
November 11, 2026 09:51
9e0e078 to
457706d
Compare
Author
|
@0x70b1a5 Thanks! I added your four cases as an evaluator unit test (credited in the commit) and switched to your shape: |
abgrad
force-pushed
the
actualtext-marked-content
branch
from
November 11, 2026 11:36
457706d to
3f286be
Compare
Author
|
Splendid! |
The first visible glyph of a marked content sequence with an /ActualText gets that text and its other glyphs get none, while positions and spaces are computed as before. The outermost /ActualText applies, also in Form XObjects, and a sequence left open in a text object ends at ET in both modes. Whitespace alone turns the glyphs into spaces, and text without a visible char is ignored. Named property lists are resolved, which also gives the MCID of such sequences. The PDFDocEncoding, UTF-16BE, non-string and missing /ActualText test cases come from PR 22473 by 0x70b1a5. Co-authored-by: 0x70b1a5 <10970247+0x70b1a5@users.noreply.github.com>
abgrad
force-pushed
the
actualtext-marked-content
branch
from
November 13, 2026 10:00
3f286be to
019e5ed
Compare
This branch has not been deployed
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.
getTextContent now applies the /ActualText of marked content (section 14.9.4): the first visible glyph of the sequence gets the text, its other glyphs get none, and positions, spaces and line breaks are computed as before. It works the same with and without includeMarkedContent, so the text layer, find and the text under highlight annotations all get it. No new API.
This picks up the approach of #20014 and covers what it misses: named property lists (/Span /P0 BDC), nested sequences (the outermost /ActualText applies), sequences over several lines or without glyphs, a sequence left open at ET, and Form XObjects inside a sequence. Whitespace alone turns the glyphs into spaces; text without a visible char (e.g. the soft hyphen of issue 13226) is ignored.
It fixes the PDFs of issue #12237: Chrome-printed variable fonts whose Type3 glyphs map to U+0000 while a Span names the character.
Corpus check (local and linked test PDFs, first 10 pages, both modes): 1118 of 1121 files give identical text items. Changed:
Tests: api_spec builds its PDFs with assemblePdf, no new files. The PDFDocEncoding, UTF-16BE, non-string and missing /ActualText cases come from #22473 by 0x70b1a5.