I have made a pdf template with a multi-line textbox and have to set some Arabic data in the Acrofields using PDFStamper. The run direction of text is correct for the first line but it changes when text wrapping occurs.
Please guide.
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);
}
}