Prashant Verma

Prashant Verma

  • 0
  • 77
  • 1.1k

pdf is not showing correct hindi.

Feb 22 2019 12:17 AM
I am  using  itextsharp.dll   hindi  in pdf is not showing correctly.
 
 
 
Code
 
  1. HttpResponse response = HttpContext.Current.Response;  
  2.          response.Clear();  
  3.          response.Buffer = true;  
  4.          response.Charset = "";  
  5.          response.Cache.SetCacheability(HttpCacheability.NoCache);  
  6.          response.ContentType = "application/octet-stream";  
  7.   
  8.          response.AddHeader("Content-Disposition""attachment;filename=Service_History.pdf");  
  9.          response.ContentEncoding = System.Text.Encoding.Unicode;  
  10.          Document document = new Document();  
  11.          PdfWriter.GetInstance(document, response.OutputStream);  
  12.          document.Open();  
  13.          using (StringWriter sw = new StringWriter())  
  14.          {  
  15.              using (HtmlTextWriter htw = new HtmlTextWriter(sw))  
  16.              {  
  17.                  StringReader sr = new StringReader(sw.ToString());  
  18.                  iTextSharp.text.Document pdfDoc = new Document(PageSize.A4, 60f, 60f, 50f, 10f);  
  19.                  HTMLWorker htmlparser = new HTMLWorker(pdfDoc);  
  20.                  PdfWriter.GetInstance(pdfDoc, response.OutputStream);  
  21.                  pdfDoc.Open();  
  22.                  // BaseFont bf = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\Utsaah.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);  
  23.                  // BaseFont bf = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\Mangal.TTF", BaseFont.IDENTITY_H, true);  
  24.   
  25.                  BaseFont bf = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\ARIALUNI.TTF", BaseFont.IDENTITY_H, true);  
  26.                  PdfPTable table = new PdfPTable(dt_excel.Columns.Count);  
  27.                  table.WidthPercentage = 100;  
  28.                  table.HorizontalAlignment = 1;  
 

Answers (1)