title: Unable to left-align nested tables inside a cell
body: <p>the following code does produce the table and the nested table.
  However, the nested table is always aligned in the middle.
  I have no clue how to achieve horizontal alignment properly.</p>
  
  <p>The following method is simply looping through a list.
  when it's a simple question, I will add an TextField.
  if it's a question containing multiple answers, i will inject a nested table with the checkboxes and the values.</p>
  
  <pre><code>   private PdfPTable CreateQuestionTable(RLQuestionRecordList questions)
      {
          PdfPCell cell;
          PdfPTable table = new PdfPTable(2);
          //table.SetWidths(new int[]{ 50, 50 });
          table.WidthPercentage = 100;
          table.SpacingBefore = 20;
          table.SpacingAfter = 20;
          table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
          foreach (RCQuestionRecord q in questions)
          {
              //add question to the table
              cell = new PdfPCell(new Phrase(q.ssSTQuestion.ssName, _Normal));
              cell.Border = Rectangle.NO_BORDER;
              cell.Padding = 5.0f;
              table.AddCell(cell);
  
              //add answer to the table.
              //add generate time we don;t know where the table will be,
              //hence textfields will be generated after the pdf has been generated..
  
              if (q.ssSTQuestion.ssListOfAnswers.Length &gt; 0)
              {
                  // we have radiobuttons, so we add a table inside the cell
                  cell = new PdfPCell();
                  cell.Border = Rectangle.NO_BORDER;
                  cell.Padding = 5.0f;
                  //we cannot align the table to the left in the cell for some weird reason...
                  cell.HorizontalAlignment = Element.ALIGN_LEFT;
                  cell.AddElement(CreateCheckboxTable(q));
                  table.AddCell(cell);
              }
              else
              {
                  // we have simple textfield, so add that to the cell
                  cell = new PdfPCell();
                  cell.Border = Rectangle.NO_BORDER;
                  cell.Padding = 5.0f;
                  cell.HorizontalAlignment = Element.ALIGN_LEFT;
                  //simple textfield
                  cell.CellEvent = new OOMTextField(string.Format("question_{0}", q.ssSTQuestion.ssQuestionId), q.ssSTQuestion.ssLength, q.ssSTQuestion.ssValue, bf);
                  table.AddCell(cell);
              }
          }
          return table;
      }
  </code></pre>
  
  <p>This is the nested table I want to insert into the cell above.</p>
  
  <pre><code>    /// &lt;summary&gt;
      /// 
      /// &lt;/summary&gt;
      /// &lt;param name="question"&gt;&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      private PdfPTable CreateCheckboxTable(RCQuestionRecord question)
      {
          PdfPCell cell;
          int numCells = question.ssSTQuestion.ssListOfAnswers.Length;
  
          PdfPTable table = new PdfPTable(numCells);
          float[] widths = new float[numCells];
  
          int currentColumn = 0;
          //table.SetWidths(new int[]{ 50, 50 });
          foreach (RCAnswerRecord a in question.ssSTQuestion.ssListOfAnswers) {
              //checkbox
              cell = new PdfPCell(new Phrase(a.ssSTAnswer.ssLabel, _Normal));
              cell.Border = Rectangle.NO_BORDER;
              cell.Padding = 0.0f;
              cell.PaddingLeft = 20.0f;
              cell.HorizontalAlignment = Element.ALIGN_LEFT;
              cell.VerticalAlignment = Element.ALIGN_CENTER;
              cell.CellEvent = new OOMCheckBox(string.Format("question_{0}", question.ssSTQuestion.ssQuestionId), a.ssSTAnswer.ssIsSelected, a.ssSTAnswer.ssLabel, bf);
              //checkbox
              table.AddCell(cell);
              widths[currentColumn++] = 20.0f + bf.GetWidthPoint(a.ssSTAnswer.ssLabel, 11); 
          }
  
          table.SetTotalWidth(widths);
          table.LockedWidth = true;
          table.SpacingBefore = 0;
          return table;
      }
  </code></pre>
  
  <p>What am I missing to align the nested tables totally to the left inside the cell?</p>