title: iTextSharp Display only certain DataGridView columns
body: <p>I want to display only certain DataGridView columns in a PDF file using iTextSharp. I know you can insert the whole GridView into the PDF document. But is it possible to only show certain columns of the DataGridView?</p>
  
  <p>This is my code so far :</p>
  
  <pre><code>        iTextSharp.text.Font fontTable = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
  
          PdfPTable table = new PdfPTable(dataGridView1.Columns.Count);
          table.SpacingBefore = 45f;
          table.TotalWidth = 300;
          table.DefaultCell.Phrase = new Phrase() { Font = fontTable };
  
          for (int j = 0; j &lt; dataGridView1.Columns.Count; j++)
          {
              table.AddCell(new Phrase(dataGridView1.Columns[j].HeaderText, fontTable));
  
          }
  
          table.HeaderRows = 1;
  
          for (int i = 0; i &lt; dataGridView1.Rows.Count; i++)
          {
              for (int k = 0; k &lt; dataGridView1.Columns.Count; k++)
              {
                  if (dataGridView1[k, i].Value != null)
                  {
                      table.AddCell(new Phrase(dataGridView1[k, i].Value.ToString(),fontTable));
                  }
              }
          }
  
  
  
          doc.Add(table);
  </code></pre>