I put some values to form fields using following code .
//-------------------------------------------------------
PdfReader reader = new PdfReader(in);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(out));
AcroFields form = stamper.getAcroFields();
form.setField("txt_1", "TEST:ทดสอบ");
stamper.close();
reader.close();
//-------------------------------------------------------
the problem is Thai character does not display in the PDF reader until I focus on that field .
** first time I opened output file I got
FieldName: Text:
when I focus on the field the result is correct and after I click on another field, Thai characters is disappear again
FieldName: Text:ทดสอบ
can anyone please help. Thanks
Please read my answer to Can't get Czech characters while generating a PDF first. It is about Czech characters, but it is also relevant for your question:
Then read Chapter 8 of my book. More specifically the text that explains figure 8.3 and figure 8.4. In figure 8.3, the upper document shows the problem you are experiencing. In this case, we are adding a
String
with Western text as well as Chinese text as a field value. The Western text is shown, the Chinese text isn't. The second and third window, show what happens when you fill out the field correctly. In figure 8.3, we try adding some Korean text. This fails in the first and third window, but we solved the problem in the second, third and fourth window.If you do not own a copy of my book, you may benefit from trying the TextFieldFont example that produces all the PDFs shown in the screen shots.
Suppose that you would decide to use MS Arial Unicode, you'd choose the solution where this font is added as substitution font:
There are, of course, other options, but this is one way to solve your problem.