Hello. I am having problems trying to implement the PDF components for .NET. I am getting the following error when I try to open the document that is created with the code below: PDF Error: here was an error opening this document. This file is damaged and could not be repaired
It is always 167 KB, regardless of what I place in it. I have tried writing out both simple strings and the contents of an ASP.NET Listview control and they both produce the same results. Please let me know if there are other steps that I need to take.
Pdf pdf = new Pdf();
using (MemoryStream memoryStream = new MemoryStream(100))
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
htmlTextWriter.Write("hello, this is cool.");
UnicodeEncoding uniEncoding = new UnicodeEncoding();
byte reportArray = uniEncoding.GetBytes(stringWriter.ToString());
// Write the first string to the stream.
memoryStream.Write(reportArray, 0, reportArray.Length);
pdf.Save("testdoc.pdf", SaveType.OpenInAcrobat, HttpContext.Current.Response);