title: PDF text replace not working
body: <p>I'm trying to replace text in PDF using iTextSharp dll but its not working in all cases. PDF document doesn't have acro fields. </p>
  
  <p>If the text which I need to replace is bigger than original text its not printing all characters. Finding some special characters is also not working.</p>
  
  <p>I have tried this code</p>
  
  <pre><code>using (PdfReader reader = new PdfReader(sourceFileName))
  {
      for (int i = 1; i &lt;= reader.NumberOfPages; i++)
      {
          byte[] contentBytes = reader.GetPageContent(i);
          string contentString = PdfEncodings.ConvertToString(contentBytes, PdfObject.TEXT_PDFDOCENCODING);
          contentString = contentString.Replace("SOMETEXT", "NEWBIGGERTEXT");                 
          reader.SetPageContent(i, PdfEncodings.ConvertToBytes(contentString, PdfObject.TEXT_PDFDOCENCODING));
      }
      new PdfStamper(reader, new FileStream(newFileName, FileMode.Create, FileAccess.Write)).Close();
  }
  </code></pre>
  
  <p>Please let me know how this can be achieved. </p>