title: How do I Combine/Merge PDFs with Fillable Form Fields using iTextSharp?
body: <p>Using <code>iTextSharp</code>, how can I merge multiple PDFs into one PDF without losing the Form Fields and their properties in each individual PDF?</p>
  
  <p>(I would prefer an example using streams from a database but file system is ok as well)</p>
  
  <p>I found <a href="http://www.vbforums.com/showthread.php?t=475920" rel="noreferrer">this code</a> that works but it flattens out my PDFs so I can't use it.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>@Mark Storer - This is the code I am using now based on your feedback (see below) but it gives me a corrupt document after the save.  I tested each of the code parts separately and it seems to be failing in the <code>MergePdfForms</code> function shown below.  I obviously don't want to use the <code>renameFields</code> part of your example because I need the field names to remain "as is".</p>
  
  <pre><code>Public Sub MergePdfForms(ByVal pdfFiles As ArrayList, ByVal outputPath As String)
      Dim ms As New IO.MemoryStream()
      Dim copier As New PdfCopyFields(ms)
      For Each pfile As String In pdfFiles
          Dim reader As New PdfReader(pfile)
          copier.AddDocument(reader)
      Next
      SaveMemoryStream(ms, outputPath)
      copier.Close()
  End Sub
  
  Public Sub SaveMemoryStream(ms As IO.MemoryStream, FileName As String)
      Dim outStream As IO.FileStream = IO.File.OpenWrite(FileName)
      ms.WriteTo(outStream)
      outStream.Flush()
      outStream.Close()
  End Sub
  </code></pre>