title: Can not access a closed stream Itext7
body: <p>I am using itext7 for PDF manipulation. I am trying to fill form fields by field.setValue method. My _Reader object is filled at constructor level and is used on Adding and Getting form fields. But on Saving form field value, on closing PdfDocument object following exception is caught:</p>
  
  <pre><code>at System.IO.__Error.StreamIsClosed()
  at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
  at iText.IO.Source.OutputStream`1.Write(Byte[] b, Int32 off, Int32 len)
  at iText.IO.Source.OutputStream`1.WriteInteger(Int32 value)
  at iText.Kernel.Pdf.PdfWriter.WriteToBody(PdfObject pdfObj)
  at iText.Kernel.Pdf.PdfWriter.FlushObject(PdfObject pdfObject, Boolean 
  canBeInObjStm)
  at iText.Kernel.Pdf.PdfDocument.FlushObject(PdfObject pdfObject, Boolean 
  canBeInObjStm)
  at iText.Kernel.Pdf.PdfObject.Flush(Boolean canBeInObjStm)
  at iText.Kernel.Pdf.PdfPage.Flush(Boolean flushResourcesContentStreams)
  at iText.Kernel.Pdf.PdfPage.Flush()
  at iText.Kernel.Pdf.PdfDocument.Close()
  </code></pre>
  
  <p>Code snippet is as following:</p>
  
  <pre><code>using (var memoryStream = new MemoryStream())
          {
              PdfDocument document = new PdfDocument(_Reader, new PdfWriter(memoryStream));
              PdfAcroForm Form = PdfAcroForm.GetAcroForm(document, true);
              foreach (PDFField Field in PDFFields)
              {
                  PdfFormField formField = Form.GetField(Field.Name);
  
                  switch (Field.Type)
                  {
                      case PDF_FIELD_TYPE.TEXTBOX:
                          if (!string.IsNullOrEmpty(Field.Value))
                              formField.SetValue(Field.Value);
                          else
                              formField.SetValue(string.Empty);
                          break;
                  }
              }
              document.Close();
              byte[] PDFBytes = ((MemoryStream)memoryStream).ToArray();
  </code></pre>
  
  <p>Thanks in advance for help.</p>