public void createPdf(String filename) throws IOException, DocumentException {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.add(Chunk.NEWLINE);
FontFactory.register("c:/windows/fonts/tradbdo.ttf", "my_arabic");
Font myArabicFont = FontFactory.getFont("my_arabic" ,BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
PdfPTable table = new PdfPTable(1);
table.getDefaultCell().setNoWrap(false);
// table.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
PdfPCell text = new PdfPCell(new Phrase("محمود السنباطيthis is أبتثجحخدرزسشصضطظعغفقكلمنهوى", myArabicFont));
text.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
text.setNoWrap(false);
table.addCell(text);
//Add the table to the document
document.add(table);
document.close();
}
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.add(Chunk.NEWLINE);
FontFactory.register("c:/windows/fonts/tradbdo.ttf", "my_arabic");
Font myArabicFont = FontFactory.getFont("my_arabic" ,BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
PdfPTable table = new PdfPTable(1);
table.getDefaultCell().setNoWrap(false);
// table.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
PdfPCell text = new PdfPCell(new Phrase("محمود السنباطيthis is أبتثجحخدرزسشصضطظعغفقكلمنهوى", myArabicFont));
text.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
text.setNoWrap(false);
table.addCell(text);
//Add the table to the document
document.add(table);
document.close();
}
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteits not working man !!! i have tried a lot !!!
ReplyDelete==========================================================================
PdfPTable table = new PdfPTable(1);
table.DefaultCell.NoWrap = false;
PdfPCell text = new PdfPCell(new Phrase("محمود السنباطيthis is أبتثجحخدرزسشصضطظعغفقكلمنهوى", secondHeadingFontArabic));
text.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
text.NoWrap = false;
table.AddCell(text);
document.Add(table)