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);
Comments
Post a Comment