title: export arabic data to pdf using itext
body: <p>I want to export gridview data to PDF, using iTextsharp. The gridview data contains Persian/Arabic data. It results in just a blank PDF file... what could be the reason?</p>
  
  <p>Following is my code:</p>
  
  <pre><code>    GridView1.DataSource = Session("dt")
      GridView1.AllowPaging = False
      GridView1.DataBind()
  
      Dim bf As BaseFont = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") &amp; "\fonts\tahoma.ttf", BaseFont.IDENTITY_H, True)
      Dim font As New iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL)
      Dim table As New iTextSharp.text.pdf.PdfPTable(GridView1.Columns.Count)
      Dim widths As Integer() = New Integer(GridView1.Columns.Count - 1) {}
      For x As Integer = 0 To GridView1.Columns.Count - 1
          widths(x) = CInt(GridView1.Columns(x).ItemStyle.Width.Value)
          Dim cellText As String = Server.HtmlDecode(GridView1.HeaderRow.Cells(x).Text)
          Dim cell As New iTextSharp.text.pdf.PdfPCell(New Phrase(12, cellText, font))
          cell.BackgroundColor = New BaseColor(GridView1.HeaderStyle.BackColor)
          'cell.BackgroundColor = New BaseColor(System.Drawing.ColorTranslator.FromHtml("#008000"))
          cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL
          table.AddCell(cell)
      Next
      table.SetWidths(widths)
  
      For i As Integer = 0 To GridView1.Rows.Count - 1
          If GridView1.Rows(i).RowType = DataControlRowType.DataRow Then
              For j As Integer = 0 To GridView1.Columns.Count - 1
                  Dim cellText As String = Server.HtmlDecode(GridView1.Rows(i).Cells(j).Text)
                  Dim cell As New iTextSharp.text.pdf.PdfPCell(New Phrase(12, cellText, font))
                  'Set Color of Alternating row
                  If i Mod 2 &lt;&gt; 0 Then
                      'cell.BackgroundColor = New BaseColor(System.Drawing.ColorTranslator.FromHtml("#C2D69B"))
                      cell.BackgroundColor = New BaseColor(GridView1.RowStyle.BackColor)
                  End If
                  cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL
                  table.AddCell(cell)
              Next
          End If
      Next
  
      'Create the PDF Document
      Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 0.0F)
      PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
      pdfDoc.Open()
      pdfDoc.Add(table)
      pdfDoc.Close()
      Response.ContentType = "application/pdf"
      Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf")
      Response.Cache.SetCacheability(HttpCacheability.NoCache)
      Response.Write(pdfDoc)
      Response.[End]()
  </code></pre>