title: iTextSharp VB.Net - Fixing the formatting of my table to properly display in PDF
body: <p>So far I keep getting PDF's life these:</p>
  
  <p><img src="https://i.stack.imgur.com/qdabN.png" alt="enter image description here"></p>
  
  <p>I just want to have a PDF file that displays them like an Excel would. Example:
  <img src="https://i.stack.imgur.com/OmWgb.png" alt="enter image description here"></p>
  
  <p>How do I make my iTextSharp values to display properly? I just want my words to line up straight instead of cutting them in halves. My button code is shown below: A4.Rotate as suggested by @JoshPart</p>
  
  <pre><code>Dim pdfTable As New PdfPTable(DataGridView1.ColumnCount)
  
      'Add Title of PDF
      Dim cell1 As New PdfPCell(New Phrase(StudentToolStripMenuItem.Text))
      cell1.Colspan = 28
      cell1.Border = 0
      cell1.HorizontalAlignment = 1
      pdfTable.AddCell(cell1)
  
      'Creating iTextSharp Table from the DataTable data
      pdfTable.DefaultCell.Padding = 3
      pdfTable.WidthPercentage = 100
      pdfTable.HorizontalAlignment = Element.ALIGN_LEFT
      pdfTable.DefaultCell.BorderWidth = 1
  
  
      'Adding Header row
      For Each column As DataGridViewColumn In DataGridView1.Columns
          Dim cell As New PdfPCell(New Phrase(column.HeaderText))
          cell.BackgroundColor = New iTextSharp.text.BaseColor(240, 240, 240)
          pdfTable.AddCell(cell)
      Next
  
      'Adding DataRow
      For Each row As DataGridViewRow In DataGridView1.Rows
          If row.IsNewRow = False Then
              For Each cell As DataGridViewCell In row.Cells
                  pdfTable.AddCell(cell.Value.ToString())
              Next
          End If
      Next
  
      'Exporting to PDF
      Dim folderPath As String = "C:\Mickosis\Class Manager\PDFs\"
      If Not Directory.Exists(folderPath) Then
          Directory.CreateDirectory(folderPath)
      End If
      Using stream As New FileStream(folderPath &amp; StudentToolStripMenuItem.Text &amp; ".pdf", FileMode.Create)
          Dim pdfDoc As New Document(PageSize.A4.Rotate, 5.0F, 5.0F, 5.0F, 5.0F)
          PdfWriter.GetInstance(pdfDoc, stream)
          pdfDoc.Open()
          pdfDoc.Add(pdfTable)
          pdfDoc.Close()
          stream.Close()
      End Using
  
      MsgBox("PDF Created", , msgboxtitle)
  </code></pre>