c# - iTextSharp does not render Custom urdu font -


i using custom urdu font jameel noori nastaleeq itextsharp not showing text @ all. shows text when use built-in forms times.ttf etc.

code given below:

private void button1_click(object sender, eventargs e)         {              document document = new document();             try             {                 pdfwriter writer = pdfwriter.getinstance(document, new system.io.filestream("c:\\itextsharphelloworld.pdf", system.io.filemode.create));                 document.open();                 string fontpath = environment.getenvironmentvariable("systemroot") + "\\fonts\\jameel noori nastaleeq.ttf";                 //string fontpath = environment.getenvironmentvariable("systemroot") + "\\fonts\\times.ttf";                 basefont basefont = basefont.createfont(fontpath, basefont.identity_h, basefont.embedded);                 itextsharp.text.font arabicfont = new itextsharp.text.font(basefont, 24, itextsharp.text.font.normal, itextsharp.text.basecolor.blue);                 var el = new chunk();                 itextsharp.text.font f2 = new itextsharp.text.font(basefont, el.font.size,                 el.font.style, el.font.color);                 el.font = arabicfont;                 pdfptable table = new pdfptable(1);                  table.rundirection = pdfwriter.run_direction_rtl;                   var str = "نام : ";                 pdfpcell cell = new pdfpcell(new phrase(10, str, el.font));                 table.addcell(cell);                  document.add(table);                 document.close();                 messagebox.show("done");              }             catch (documentexception de)             {                 // this.message = de.message;                 messagebox.show(de.message);             }             catch (system.io.ioexception ioe)             {                 // this.message = ioe.message;                 messagebox.show(ioe.message);             }              // step 5: close document             document.close();         }     } 

update: setting cell.arabicoptions = columntext.digits_en2an; render font in desired font not other text.

to write in arabic use following font:

here example create order in arabic same urdu

basefont basefontarabic = basefont.createfont("c:\\\\windows\\\\fonts\\\\times.ttf", basefont.identity_h, true); itextsharp.text.font farabicnormal = new itextsharp.text.font(basefontarabic, 10, itextsharp.text.font.normal); itextsharp.text.font farabicbold = new itextsharp.text.font(basefontarabic, 12, itextsharp.text.font.bold);   `document document = new document(pagesize.a4);                 document.setmargins(10f, 10f, 10f, 30f);                 pdfwriter writer = pdfwriter.getinstance(document, new filestream(filename+ ".pdf", filemode.create));                  document.open();                  pdfptable table = new pdfptable(5) { rundirection = pdfwriter.run_direction_rtl, headerrows = 1 };                 table.setwidths(new float[] { 1, 1, 1, 2, 1 });                  table.addcell(new pdfpcell(new phrase("الكمية", reportdesigner.farabicnormal)) { grayfill = 0.95f, horizontalalignment=element.align_center });                 table.addcell(new pdfpcell(new phrase("نوع السلعة", reportdesigner.farabicnormal)) { grayfill = 0.95f, horizontalalignment = element.align_center });                 table.addcell(new pdfpcell(new phrase("الوزن الصافي", reportdesigner.farabicnormal)) { grayfill = 0.95f, horizontalalignment = element.align_center });                 table.addcell(new pdfpcell(new phrase("س . ف", reportdesigner.farabicnormal)) { grayfill = 0.95f, horizontalalignment = element.align_center });                 table.addcell(new pdfpcell(new phrase("الجملة", reportdesigner.farabicnormal)) { grayfill = 0.95f, horizontalalignment = element.align_center });                  foreach (orderdetailsentity item in order.details)                 {                     table.addcell(new pdfpcell(new phrase(item.quantité.tostring("n3"), reportdesigner.farabicnormal)));                     table.addcell(new pdfpcell(new phrase(item.articlelignefacture.désignation, reportdesigner.farabicnormal)));                     table.addcell(new pdfpcell(new phrase(item.qantitéemballage.tostring("n3"), reportdesigner.farabicnormal)));                     table.addcell(new pdfpcell(new phrase(item.prixachatunitaire.tostring("n3"), reportdesigner.farabicnormal)));                     table.addcell(new pdfpcell(new phrase(item.totallignefacture.tostring("n3"), reportdesigner.farabicnormal)));                 } document.add(table);                 document.close();`   

output


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -