title: ITextSharp - Adding a Watermark; Leaving the PDF editable - FormFlattening = false
body: <p>We have a large amount of PDF files that we are creating a web site to allow users to download them and when they do we want to:</p>
  
  <ol>
  <li>Put a watermark on it with their name.</li>
  <li>We want the form fields to be left open so they can enter their information.</li>
  <li>We want to be able to print and save the document</li>
  </ol>
  
  <p>When I put the Watermark on the document and then open it I get a message from Adobe:</p>
  
  <blockquote>
    <p>"The document has been changed since it was created and use of extended features is no longer available. Please contact the author..."</p>
  </blockquote>
  
  <p>According the book "iText-in-Action", this is a security issue (Chapter 8). There seems to be 2 ways to open them:</p>
  
  <ol>
  <li>Remove usage rights : This breaks # 3 above.</li>
  <li>Open it in append mode : It does not matter if modify it and save it with "FormFlattening = false" or true, if I put a water mark on the form the fields are no longer editable.</li>
  </ol>
  
  <p>The error message from Adobe does describe the problem, I have modified the content of the document with the watermark, and the form fields become blocked because of this. 
  I have tried opening the document putting the watermark on it and saving it to a new file, and then closing it. Then reopening it and the trying to unblock the form fields, but it does not work. </p>
  
  <p>Does anyone know if this is possible?
  I have read something about templates; I don't know if this is a solution because of the work to convert the documents to templates? Does anyone know if this would help?</p>
  
  <p>Below is a sample of my code for using an Image as a watermark, although I have tried adding text as well:</p>
  
  <pre><code>        PdfReader reader = new PdfReader(sourceFile.FullName);
          //reader.RemoveUsageRights();
  
          var fileStream = new FileStream(outputPath, FileMode.Create, FileAccess.ReadWrite);
  
          PdfStamper pdfStamper = new PdfStamper(reader, fileStream, '\0', true);
  
  
          Image image = Image.GetInstance(imagePath);
          image.SetAbsolutePosition(250, 300);
  
          for (int i = 1; i &lt;= reader.NumberOfPages; i++) // Must start at 1 because 0 is not an actual page.
          {
              PdfContentByte pdfPageContents = pdfStamper.GetUnderContent(i);
  
              pdfPageContents.AddImage(image);
          }
  
          pdfStamper.FormFlattening = false; // enable this if you want the PDF flattened. 
          //bool have = pdfStamper.PartialFormFlattening("test");
          pdfStamper.Close(); // Always close the stamper or you'll have a 0 byte stream. 
  </code></pre>