I am creating PDF with pre filled values in Chinese but when opening the PDF all the textfields containing Chinese text are empty. When focusing a textfield the Chinese text comes visible but is hided again when unfocusing the field. What could be the issue?
1 Answers
Please share some more info, as there could be more than one reason why the appearances aren't generated by iText.
A. The first reason is explained in the StackOverflow question "AcroForm values missing after flattening". In this case, the PDF contains a parameter that instructs iText not to generate appearances, which would explain why you don't see any value up until you click the field, in which case the viewer will create them.
B. The second reason is explained in section 8.3.3 (entitled "Text fields and fonts") of my book. In this case, the parameter in the PDF doesn't prevent the creation of field appearances, but iText fails to do so because you're not providing a font that knows how to display the Chinese characters.
See for instance figure 8.3 and 8.4 of the book.
In figure 8.3, you see that Chinese text isn't displayed in the upper window. By fixing the form (using two different strategies), the Chinese text appears in the lower two windows. Note that the Chinese text won't appear in all viewers in the case of the middle window.
In figure 8.4, you see that Korean text isn't displayed in the upper window, nor in the third window. In all other windows, different strategies were used to fix this problem:
It would lead us too far to discuss all the different strategies in an answer on SO. Instead, please take a look at the TextFontFields example (for the C# version, please take a look at the ported examples). My guess is that you'll benefit most from the AddSubstitutionFont()
method, provided that you use a font of which a subset will be embedded in the document (in the example arialuni.ttf
is used).
In case of A., the phenomenon also concerns other languages. In case of B., the parameter is correct, but you're not providing a font that can be used to generate the appearance.

- 1
- 1

- 75,994
- 9
- 109
- 165
-
Setting NeedAppearances=True and reducing size of font solved problem.Thx! – user3733216 Jan 30 '14 at 13:08
-
OK, just take into account that not all users will see the text when you depend on the viewer to generate the appearances: not all systems have the required font on their system. – Bruno Lowagie Jan 30 '14 at 13:17
-
I run into new issue: so when setting neededapperance=true the pre-selected radiobutton selections are not visible anymore, any ideas? – user3733216 Feb 07 '14 at 08:30
-
When Adobe Reader creates the appearances, the default appearance for radio buttons and check boxes is used. This means that nothing is shown when the button or box isn't selected. That's normal. In such a case, it is expected that the circle, square, or whatever shape that denotes the button is part of the content stream. Note that it's against the rules of SO to post new questions in the comment section. New questions require a... new question. – Bruno Lowagie Feb 07 '14 at 08:59
-
we solved it by using the AddSubstitutionFont() method instead of the NeedAppearances=True. Sorry for posting this question here, will in future make new question. – user3733216 Feb 07 '14 at 09:55
-
That's why there are different strategies available ;-) – Bruno Lowagie Feb 07 '14 at 09:55