title: itextsharp error generated when parsing html
body: <p>Good day,
  Ive just started working with itextsharp to generate pdfs. I keep getting an error when i try to do so. But when i generate the pdf in an override of the render method it seems to work..</p>
  
  <p>This is the code on the button click:</p>
  
  <pre><code>protected void btnExport_Click(object sender, EventArgs e)
  {
      string htmlMarkup = createPdf.GetHtmlPage(HttpContext.Current.Request.Url.AbsoluteUri);
  
      try
      {
          createPdf.GeneratePDF(htmlMarkup);
      }
      catch (Exception ex)
      {
          lblmessage.Text = ex.Message;
          throw;
      }
  }
  </code></pre>
  
  <p>And the code in the generate class:</p>
  
  <pre><code>    public void GeneratePDF(string pdfBody)
      {
  
  
          var document = new Document();
  
          // TODO : Write to Memory Stream
          var writer = PdfWriter.GetInstance(document, memStream);
  
          document.Open();
          iTextSharp.text.html.simpleparser.StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
          iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document);
  
          //Why is this line not working??
          hw.Parse(new StringReader(pdfBody));
  
          document.Close();
  
           ShowPdf();
      }
  
      public string GetHtmlPage(string strURL)
      {
  
          String strResult;
          WebResponse objResponse;
          WebRequest objRequest = HttpWebRequest.Create(strURL);
  
          objRequest.UseDefaultCredentials = true;
          objRequest.PreAuthenticate = true;
          objRequest.Credentials = CredentialCache.DefaultCredentials;
  
          objResponse = objRequest.GetResponse();
          using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
          {
              strResult = sr.ReadToEnd();
              sr.Close();
          }
          return strResult;
      }
  </code></pre>
  
  <p>The error is generated at the commented line. The error is "The network path was not found.\r\n" How can i fix this?! 
  Please help
  Thanks in advance</p>