You were right; install failed and I didn't catch it since the panel was small. It has been fixed and I see it in References.
I am still getting errors when I click on button:
Error loading entities resource: I/O error occurred.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: iText.StyledXmlParser.Jsoup.MissingResourceException: Error loading entities resource: I/O error occurred.
Source Error:
Line 41: MemoryStream htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(Content));
Line 42: HtmlConverter.ConvertToPdf(htmlStream, pdfStream);
I have copied and pasted your code and haven't made any changes to it.
public bool returnPdf;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
returnPdf = true;
}
protected override void Render(HtmlTextWriter Writer)
{
string Content = string.Empty;
MemoryStream pdfStream = new MemoryStream();
if (returnPdf)
{
using (StringWriter stringWriter = new StringWriter())
{
using (HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(stringWriter))
{
base.Render(HtmlTextWriter);
HtmlTextWriter.Close();
// get the page content
Content = stringWriter.ToString();
//Get a PDF stream
MemoryStream htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(Content));
HtmlConverter.ConvertToPdf(htmlStream, pdfStream);
}
}
// render the PDF content
Response.ContentType = "application/pdf";
Response.BinaryWrite(pdfStream.ToArray());
Response.End();
Response.Flush();
Response.Clear();
}
else
{
//Render HTML content
using (StringWriter stringWriter = new StringWriter())
{
using (HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(stringWriter))
{
base.Render(HtmlTextWriter);
HtmlTextWriter.Close();
Content = stringWriter.ToString();
}
}
Writer.Write(Content);
}
}