Fix 5953 - #535
Closed
valerybokov wants to merge 2 commits into
Closed
Fix 5953#535valerybokov wants to merge 2 commits into
valerybokov wants to merge 2 commits into
Conversation
Author
|
Another issue. It looks like we don't need a method PDCIEDictionaryBasedColorSpace.isWhitePoint. |
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Sep 28, 2026
…hen the font's encoding is a predefined Uni... CMap (and not Identity-*), write the raw Unicode value as the code instead of the substitute font's glyph index, matching what that encoding's codespace actually expects, by Valery Bokov and Claude Code; closes #535 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/3.0@1938599 13f79535-47bb-0310-9956-ffa450edef68
asf-gitbox-commits
pushed a commit
that referenced
this pull request
Sep 28, 2026
…hen the font's encoding is a predefined Uni... CMap (and not Identity-*), write the raw Unicode value as the code instead of the substitute font's glyph index, matching what that encoding's codespace actually expects, by Valery Bokov and Claude Code; closes #535 git-svn-id: https://svn.apache.org/repos/asf/pdfbox/branches/2.0@1938600 13f79535-47bb-0310-9956-ffa450edef68
Contributor
|
Thanks, removed |
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
Filled-in AcroForm field values (account numbers, amounts, names) rendered as garbled or blank CJK text in a real-world bank-receipt PDF where NeedAppearances is set and the AcroForm/DR font (SimSun) is:
Root cause
PDCIDFontType2.encode()'s non-embedded branch always wrote the substituted font's own glyph index as the content-stream code, regardless of the font's declared /Encoding. That's only correct for Identity-H/V, where code == GID by convention.
For a Uni...-UTF16-H/Uni...-UCS2-H encoding, the codespace is the raw UTF-16BE Unicode value (verified directly against the UniGB-UTF16-H CMap resource, e.g. <00a4> 167). Writing the substitute font's glyph index there instead produces a code that, once decoded again through the normal CID/Unicode round trip (PDCIDFontType2#codeToGID / PDType0Font#toUnicode), resolves to an unrelated, essentially arbitrary character — hence the garbled/blank text.
Fix
In the non-embedded branch of PDCIDFontType2.encode(), when the font's encoding is a predefined Uni... CMap (and not Identity-*), write the raw Unicode value as the code instead of the substitute font's glyph index, matching what that encoding's codespace actually expects.
Testing