title: iTextsharp PdfPTable writeselectedrows
body: <p>Why can't I write a <code>PdfPTable</code> containing a <code>PdfFormField</code> to an existing PDF? iTextSharp tells me </p>
  
  <blockquote>
    <p>Unsupported in this context. Use <code>PdfStamper.addAnnotation()</code>.</p>
  </blockquote>
  
  <pre><code>Private Sub RR(PdfFileName As String)
      Dim reader As New PdfReader(PdfFileName)
      Dim RandomFileName As String = System.IO.Path.GetRandomFileName
      Dim OutputPdf As String = System.IO.Path.GetDirectoryName(PdfFileName) &amp; "\" &amp; System.IO.Path.GetFileNameWithoutExtension(RandomFileName) &amp; ".pdf"
  
      Dim stamper As New PdfStamper(reader, New FileStream(OutputPdf, FileMode.Create))
      Dim table As New PdfPTable(1)
      Dim PageMargin As Single = 20
      Dim tbCell As New PdfPCell()
  
      table.TotalWidth = (reader.GetPageSize(1).Right - reader.GetPageSize(1).Left) - 20
      Dim PDfFormField As PdfFormField = CreateTextField(stamper.Writer, "TestField", 0, 0)
      tbCell = New PdfPCell With {.CellEvent = New iTextSharp.text.pdf.events.FieldPositioningEvents(stamper.Writer, PDfFormField), .MinimumHeight = 10, .BorderWidth = 0.1}
  
      With table
          .AddCell(tbCell)
      End With
  
      table.WriteSelectedRows(0, -1, PageMargin, Bottom + table.TotalHeight + PageMargin, stamper.GetOverContent(1))
  
      stamper.Close()
      reader.Close()
  
  End Sub
  </code></pre>