title: How can I put data in specific cells in a table on a PDF form using iTextSharp?
body: <p>I want to create a table in a PDF and then assign values (phrases) to specific cells in that table.</p>
  
  <p>I would assume it would be something like this:</p>
  
  <pre><code>PdfPTable table = new PdfPTable(5); // the arg is the number of columns
  
  // Row 1
  PdfPCell cell = new PdfPCell(docTitle);
  cell.Colspan = 3;
  cell.BorderWidth = 0;
  cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
  table.AddCell(0, 0, cell); // &lt;= col 0, row 0. I would expect to be able to do something like this
  </code></pre>
  
  <p>...but the only example code I've found just adds cells to the table, one after the other, without specifying which cell of the table that cell data should be associated with. Such as:</p>
  
  <pre><code>PdfPTable table = new PdfPTable(5); // the arg is the number of columns
  
  // Row 1
  PdfPCell cell = new PdfPCell(docTitle);
  cell.Colspan = 3;
  cell.BorderWidth = 0;
  cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
  table.AddCell(cell);
  
  // Row 2
  PdfPCell cellCaveat = new PdfPCell(subTitle);
  cellCaveat.Colspan = 2;
  cellCaveat.BorderWidth = 0;
  table.AddCell(cellCaveat);
  
  // Row 3
  PdfPCell cellImportantNote = new PdfPCell(importantNotice);
  cellImportantNote.Colspan = 5;
  cellImportantNote.BorderWidth = 0;
  table.AddCell(importantNotice);
  </code></pre>
  
  <p>Is there a more specific way to add cells to a table than just one at a time, hoping they are placed in the right spot?</p>
  
  <p>Note: docTitle, subTitle, and importantNotice are Paragraphs that have already been created, like so:</p>
  
  <pre><code>var titleFont = FontFactory.GetFont(FontFactory.COURIER_BOLD, 11, BaseColor.BLACK);
  var docTitle = new Paragraph("UCSC - Direct Payment Form", titleFont);
  doc.Add(docTitle);
  </code></pre>