複数行のテキスト ボックスを含む PDF テンプレートを作成し、PDFStamper を使用して Acrofields にアラビア語のデータを設定する必要があります。テキストの実行方向は最初の行では正しいですが、テキストの折り返しが発生すると変更されます。
ガイドしてください。
package test;
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
public class TextFields{
public static final String RESULT1 = "D:/template.pdf";
public static final String RESULT2 = "D:/pdf/result.pdf";
protected int tf;
public TextFields(int tf) {
this.tf = tf;
}
public void manipulatePdf(String src, String dest) throws IOException, DocumentException {
PdfReader reader = new PdfReader(src);
FontFactory.registerDirectories();
BaseFont unicode = null;
unicode = BaseFont.createFont("D:/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
AcroFields form = stamper.getAcroFields();
stamper.getAcroFields().addSubstitutionFont(unicode);
form.setField("TextBox","اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب اب");
stamper.close();
reader.close();
}
public static void main(String[] args) throws DocumentException, IOException {
TextFields example = new TextFields(0);
example.manipulatePdf(RESULT1, RESULT2);
}
}