title: iTextSharp with special characters
body: <p>I have an aspx form in which user takes a survey and the survey is saved to the database. After saving to the database, the survey responses given by the user are displayed so the user can save the response as pdf.</p>
  
  <p>This is the function to save as pdf</p>
  
  <pre><code>//Save as PDF
  protected void SaveAsPDF_Click(object sender, EventArgs e)
  {
      Random nRandom = new Random(DateTime.Now.Second);
      string strFileName = nRandom.Next().ToString() + ".pdf";
      string target = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["NewResponsePDF"].ToString() + strFileName);
  
      string filepath = target;
      string filename = Path.GetFileName(filepath);
  
      Response.Clear();
      Response.ContentType = "application/pdf";
      Response.AddHeader("content-disposition", "attachment;filename=" + filename);
  
      Response.Cache.SetCacheability(HttpCacheability.NoCache);
      StringWriter sw = new StringWriter();
      HtmlTextWriter hw = new HtmlTextWriter(sw);
      this.Page.Form.RenderControl(hw);
      StringReader sr = new StringReader(sw.ToString());
      Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
      HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
      PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
      pdfDoc.Open();
      htmlparser.Parse(sr);
      pdfDoc.Close();
      Response.Write(pdfDoc);
      Response.End();
  }
  </code></pre>
  
  <p>It works fine and everything is well. The form has some text boxes. The user can enter text into the textbox. Sometimes, the user enters mathematical symbols like &lt;, >, =. To make sure that the textbox value is saved to the database, the following <code>ValidateRequest="false"</code> has been done in the aspx file. But, the SaveAsPDF throws up an error as it is unable to parse these symbols. </p>
  
  <p>I am pretty sure it is mostly these special symbols causing the issue with the</p>
  
  <p><code>htmlparser.Parse(sr)</code> method</p>
  
  <p>because if there are no special symbols in the text boxes, PDF is generated fine.</p>
  
  <p>Could you help me out on what I can do?/ Any pointers.</p>
  
  <p>Thank you.</p>