title: Insert an Image in PDF using ITextSharp
body: <p>I have to insert a an image in a pdf. That is, wherever I see  a text 'Signature', I have to insert an signature image there . I can do by saying absolute positions . 
  But, I am looking for how to find the position of the word 'Signature' in the pdf and insert the image.</p>
  
  <p>Appreciate ur help!</p>
  
  <p>This is the working code:</p>
  
  <pre><code> using (Stream inputImageStream = new FileStream(@"C:\signature.jpeg", FileMode.Open, FileAccess.Read, FileShare.Read))
      using (Stream outputPdfStream = new FileStream(@"C:\test\1282011\Result.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
      {
  
          var reader = new PdfReader(@"C:\Test\1282011\Input.pdf");
          var stamper = new PdfStamper(reader, outputPdfStream);
          var count = reader.NumberOfPages;
  
  
  
          iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);
          image.SetAbsolutePosition(300, 200); // Absolute position
          image.ScaleToFit(200, 30);
  
          PRTokeniser pkt = null;
          string strpages = string.Empty;
          System.Text.StringBuilder build = new System.Text.StringBuilder();
  
  
          for (int i = 1; i &lt;= count; i++)
          {
              var pdfContentByte = stamper.GetOverContent(i);
              if (pdfContentByte != null)
              {
                  pkt = new PRTokeniser(stamper.Reader.GetPageContent(i));
                  while (pkt.NextToken())
                  {
                      if (pkt.TokenType == PRTokeniser.TokType.STRING)
                      {
                          if (pkt.StringValue == "Signature")
                          {
                              pdfContentByte.AddImage(image);
                          }
  
                      }
  
                  }
              }
          }
          stamper.Close();
  
  
      }
  }
  </code></pre>
  
  <p>After some googling, I found out that I could absolute position of text as follows:</p>
  
  <pre><code>extSharp.text.pdf.AcroFields fields = stamper.AcroFields;
                 IList&lt;iTextSharp.text.pdf.AcroFields.FieldPosition&gt; signatureArea = fields.GetFieldPositions("Signature");
                  iTextSharp.text.Rectangle rect=  signatureArea.First().position;
                  iTextSharp.text.Rectangle logoRect = new iTextSharp.text.Rectangle(rect);
                  image.SetAbsolutePosition(logoRect.Width ,logoRect .Height );
  </code></pre>
  
  <p>But the variable , signatureArea is null all the time even when the pdf contains the word 'Signature'.</p>
  
  <p>Any input..? :)
  Jaleel</p>