0

I am trying to generate Pdf using itextsharp and I want GUJARTATI font too in that pdf. I had try but it was display blank. Kindly suggest me how I do that ?

Thank you

Here ScreenCut of Pdf :

pdf Screencut

Here Code which I try :

Document document = new Document(PageSize.A4);
document.SetMargins(88f, 88f, 80f, 30f);
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
{
    DateTime now = DateTime.Now;
    PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
    Phrase phrase = new Phrase();
    PdfPCell cell = null;
    PdfPTable maintable = null;
    PdfPTable table = null;
    PdfPTable secondTable = null;
    PdfPCell TableCell = new PdfPCell();
    PdfPCell secondTableCell = new PdfPCell();
    secondTableCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
    iTextSharp.text.Color color = null;
    document.Open();
    string ARIALUNI_TFF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF");
    BaseFont bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    Font f = new Font(bf, 12, Font.NORMAL);
    table = new PdfPTable(1);
    table.TotalWidth = 500f;
    table.LockedWidth = true;
    table.SetWidths(new float[] { 10f });
    cell = new PdfPCell(new Phrase(12, "Yes Boss નમસ્તે", f));
    cell.BorderColor = new iTextSharp.text.Color(229, 229, 229);                        
    table.AddCell(cell);
    document.Add(table);                        
    string filename = "";
    filename = "New" + now.Hour.ToString("00") + now.Minute.ToString("00") + now.Second.ToString("00") + now.Millisecond.ToString() + now.DayOfYear.ToString("000") + now.Day.ToString("00") + now.Month.ToString("00") + now.Year.ToString("0000") + ".pdf";
    document.Close();
    byte[] bytes = memoryStream.ToArray();
    memoryStream.Close();
    Response.Clear();
    Response.ContentType = "application/pdf";
    Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + "");
    Response.Buffer = true;
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.BinaryWrite(bytes);
    Response.End();
    Response.Close();
}
Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
Herry
  • 77
  • 1
  • 12

0 Answers0