I'm getting a
Object reference not set to an instance of an object.
error while using HTMLWorker.ParseToList
from iTextSharp
.
Here a part of my C# code
string htmlText = Server.UrlDecode(content);
Document document = new Document();
StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
styles.LoadTagStyle("box_wrap", "border", "1px solid #333");
styles.LoadTagStyle("box_wrap", "line-height", "22px");
styles.LoadTagStyle("box_wrap", "font-size", "12px");
styles.LoadTagStyle("li", "list-style", "none");
PdfWriter.GetInstance(document, new FileStream(strSavePath, FileMode.Create));
document.Open();
StringReader sr = new StringReader(htmlText);
List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), styles);
HTMLWorker.ParseToList
throws the error.
Here is the htmlText which i'm passing into StringReader. Here
UPDATE: removing the hr
as mentioned by @Chris in comments resolved the above error but gave way to another error Illegal characters in path
` tag that breaks things. Try turning `htmlText` into a literal string and start pruning that until things no longer break. – Chris Haas Apr 08 '14 at 21:49