title: watermark (text or image) in existing pdf
body: <p>How do I add a watermark (text or image) in an existing pdf in c#?</p>
  
  <p>I want the watermark displayed for all pages of the pdf. </p>
  
  <p>I tried with itextsharp but the watermark is displaying in only last page of the pdf. </p>
  
  <pre><code>    public void CreateTemplate(string watermarkText, string targetFileName)
      {
          var document = new Document();
          var pdfWriter = PdfWriter.GetInstance(document, new FileStream(targetFileName, FileMode.Create));
          var font = new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 60, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.LIGHT_GRAY);
          document.Open();
          ColumnText.ShowTextAligned(pdfWriter.DirectContent, Element.ALIGN_CENTER, new Phrase(watermarkText, font), 300, 400, 45);
          document.Close();
      }
      public void AddTextWatermark(string sourceFilePath, string watermarkTemplatePath, string targetFilePath)
      {
          var pdfReaderSource = new PdfReader(sourceFilePath);
          var pdfStamper = new PdfStamper(pdfReaderSource, new FileStream(targetFilePath, FileMode.Create));
          var pdfReaderTemplate = new PdfReader(watermarkTemplatePath);
          var page = pdfStamper.GetImportedPage(pdfReaderTemplate, 1);
  
          for (var i = 0; i &lt; pdfReaderSource.NumberOfPages; i++)
          {
              var content = pdfStamper.GetUnderContent(i + 1);
              content.AddTemplate(page, 0, 0);
          }
  
          pdfStamper.Close();
          pdfReaderTemplate.Close();
      }
  </code></pre>