Arabic Data disappears on Form flattening in iText

前端 未结 2 1294
不思量自难忘°
不思量自难忘° 2021-01-17 05:13

I have populated an acrofield with some Arabic data using PDFStamper. The text disappears when I flatten the form while it is working fine for English. Please guide.

相关标签:
2条回答
  • 2021-01-17 05:26

    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.

    0 讨论(0)
  • 2021-01-17 05:42

    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:

    enter image description here

    0 讨论(0)
提交回复
热议问题