title: C#/.NET: Can I get a string of valid HTML from a Stream?
body: <p>Ok, so I'm rendering a partial view control in memory that generates HTML that I would like to get to a PDF renderer. The renderer only takes a string as an argument. I have a MemoryStream containing the HTML that I need to get to the renderer.</p>
  
  <p><strong>This is what I'd like to do:</strong></p>
  
  <ul>
  <li>inStream is the MemoryStream of HTML from the partial view.</li>
  <li>doc is an instance of the PDF renderer that accepts HTML as an argument but only as a string.</li>
  </ul>
  
  <pre><code>var stream = new StreamReader(inStream);
  var html = stream.ReadToEnd();
  doc.AddHtml(html);
  </code></pre>
  
  <p><strong>The problem is that the html string has escape characters everywhere that destroy the HTML.</strong></p>
  
  <p>(image no longer available)</p>
  
  <p>I'm experimenting right now with different solutions and products in order to generate PDFs from my web app. I had an XSL-FO to PDF renderer set up that accepted a Stream as an argument and that was working just fine. If there is no way to do this then I will just look for another solution. I'm just curious if it's possible.</p>
  
  <p>Thanks!</p>