Hey. I know that many people may have asked this question before. I read almost all of them, but this could not help me solve my problem.
I am using iText java library to create Persian PDF. I am using the following code:
Document document = new Document(PageSize.A4,50,50,50,50);
FileOutputStream fos = new FileOutputStream("D:\\ITextTest.pdf");
PdfWriter writer = PdfWriter.getInstance(document,fos);
document.open();
BaseFont bf = BaseFont.createFont("C:\\Windows\\Fonts\\XB YagutBd.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font a = new Font(bf,10);
Paragraph p1 = new Paragraph("سلام دوست من");
p1.setFont(a);
document.add(p1);
document.close();
But when I execute the code, nothing was written to the PDF file and it is empty. Note that “XB YagutBd.ttf” is a Persian Unicode font, and “p1” contains some Persian characters.
What should I do? I am stuck with this problem ... help me please.
source
share