I know that many people may have asked this question before. I've read almost all of them`but it couldn't help me solve my problem. I'm using iText java library to generate a Persian PDF. I'm using the following
how to use PdfWriter.RUN_DIRECTION_RTL
code:
String ruta = txtruta.getText();
String contenido= txtcontenido.getText();
try {
FileOutputStream archivo = new FileOutputStream(ruta+".pdf");
Document doc = new Document(PageSize.A4,50,50,50,50);
PdfWriter.getInstance(doc, archivo);
doc.open();
BaseFont bfComic = BaseFont.createFont("D:\\Font\\B Lotus.ttf", BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
Font font = new Font(bfComic, 12,Font.NORMAL);
doc.add(new Paragraph(contenido,font));
doc.close();
JOptionPane.showMessageDialog(null,"ok");
} catch (Exception e) {
System.out.println("Eroor"+e);
}
Output: Problem