I fill forms with field.setValue. However even though PDF document has embedded fonts in it, I am getting error "is not available in this font's encoding: WinAnsiEncoding" no matter which type of font it is. Note that this is happening for chinese or russian characters.
Asked
Active
Viewed 161 times
1 Answers
2
Your PDF documents may have embedded fonts but they apparently have been embedded with an Encoding value WinAnsiEncoding.
WinAnsiEncoding contains essentially the Latin-15 characters, so it is intended for “Western European” languages (see the Wikipedia article on this) and in particular neither for Cyrillic nor for CJK languages.
If you want to fill chinese or russian characters into form fields using PDFBox, therefore, you have to
- either embed a font into your PDF using an appropriate encoding beforehand
- or replace the embedded font with PDFBox right before setting the form field value, see for example this answer.

mkl
- 90,588
- 15
- 125
- 265