Arabic Data disappears on Form flattening in iText

被刻印的时光 ゝ 提交于 2019-12-01 13:48:24

It's probably an encoding problem when you save, compile or execute your code (which means your problem is not related to iText). This is the code I've tried:

PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
AcroFields form = stamper.getAcroFields();
BaseFont unicode =
    BaseFont.createFont("c:/windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
form.addSubstitutionFont(unicode);
form.setField("description", "\u0628\u0627 \u0628\u0627 \u0628\u0627 \u0628\u0627 \u0628\u0627 \u0628\u0627 \u0628\u0627 \u0628\u0627 \u0628\u0627 \u0628\u0627");
stamper.close();
reader.close();

This is what the result looks like:

i had same problem. you must recreate your sourec pdf by adobe acrobat pro and set the font of your textbox to one of known fonts in your os like arial.

good luck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!