Here is my code:
Dim sr As StreamReader = New StreamReader(args(0))
Dim htmlStr As String = sr.ReadToEnd
Using document As Document = New Document()
Using writer As PdfWriter = PdfWriter.GetInstance(document, New FileStream("C:\Test\myfile.pdf", FileMode.Create))
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, New StringReader(htmlStr)) <--Error here
Can anyone help me figure out what can I do to fix this? The htm file I am reading looks fine and also there is nothing I can do to change the file itself.
The error message explains what is going wrong: the error is in your HTML.
You have a
<p> tag somewhere, and it is followed by another closing tag (only you can tell us which tag) that is not
This would be correct :
<p>This is a paragraph<br />with a new line</p>
However, this would be incorrect :
<p>This is a paragraph</br>with an incorrect new line</p>
This is also invalid :
<b>Some bold text <p>inside a paragraph</b> that is not correctly nested.</p>
The parser will understand , but throw the error you get when you have  or .