Repository navigation
Conversation
A PDF can draw glyphs whose decoded text is wrong and give the correct text in an /ActualText span. getTextContent drops this text, so a caller cannot replace the glyphs with it, as pdftotext does. Add an `actualText` property to `beginMarkedContentProps` items when the property list is an inline dictionary with a string /ActualText.
Author
|
This duplicates #22315, which was opened first. I close this PR in favour of 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.
A PDF can draw glyphs whose decoded text is wrong and give the correct text in an /ActualText span.
A common example is a small-caps font that stores each glyph in the wrong case.
pdftotext and other extractors use the span text in place of the glyphs.
getTextContent drops it, so callers cannot do the same.
This change adds an
actualTextproperty tobeginMarkedContentPropsitems.It is set only when the property list is an inline dictionary with a string /ActualText.
The value is decoded with
stringToPDFString.Other items do not change, and the text layer does not use the new property.
A caller can now replace the items between the begin and end markers with the span text.
This is the same as the replacement text rule in section 14.9.4 of the specification.
Tests: a new unit test in
evaluator_spec.jscovers a PDFDocEncoding string, a UTF-16BE string, a non-string value and no value.The test fails without the change.
The evaluator, struct tree, text layer and text content API specs pass, and
gulp lintpasses.