I am geting stackoverflow exception on htmlparse method when I have any image in my html file. I am using iTextSharp 4.0.4 dll. I also tried iTextSharp 5.0.2 dll. In that i can not find htmlparse method at all. Here under is my code:
Document doc = null;
XmlTextReader reader = null;
MemoryStream msHtml = null;
try
{
/* Convert to PDF */
doc = new Document(PageSize.A4, 10, 10, 10, 10);
string strBody = "<html>" +
"<body>" +
"<div><b>This is new page source Title</b></div>" +
"<img src=\"surfing.gif\" />"+
"<div>This is Body of the page.</div>" +
"</body>" +
"</html>";
PdfWriter.GetInstance(doc, new FileStream("htmlparse1.pdf", FileMode.Create));
msHtml = new MemoryStream(new ASCIIEncoding().GetBytes(strBody));
reader = new XmlTextReader(msHtml);
reader.WhitespaceHandling = WhitespaceHandling.None;
HtmlParser.Parse(doc, reader);
}
finally
{
/* Clean up */
if (reader != null)
reader.Close();
if (msHtml != null)
msHtml.Close();
}
Please can anyone help me out to fix this issue.