title: How to preserve CSS using iTextSharp?
body: <p>i have a header at the top of my front page like this: <img src="https://i.stack.imgur.com/ifnlU.png" alt="enter image description here"></p>
  
  <p>i use iTextSharp code to generate its PDF ... but the resulting PDF do not contain this Header with black  :  instead some CSS is written in place of header like this:</p>
  
  <p><img src="https://i.stack.imgur.com/LNmby.png" alt="enter image description here"></p>
  
  <p>How can i possibly fix this issue??</p>
  
  <p>Code:</p>
  
  <pre><code> protected void BtnPDF_Click(object sender, EventArgs e)
      {
          Response.ContentType = "application/pdf";
          Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          StringWriter sw = new StringWriter();
          HtmlTextWriter hw = new HtmlTextWriter(sw);
          this.Page.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>