I am trying to generate a PDF using HTML template.
i am having trouble in parsing the html generated. here is my code
using (FileStream fs = new FileStream(System.Web.HttpContext.Current.Server.MapPath("~/Documents/EmailTemplates/test.pdf"), FileMode.Create))
{
PdfWriter.GetInstance(document, fs);
using (StringReader stringReader = new StringReader(contents))
{
List<iTextSharp.text.IElement> parsedList = HTMLWorker.ParseToList(stringReader, null);
document.Open();
foreach (object item in parsedList)
{
document.Add((IElement)item);
}
document.Close();
}
}
i get error at HTMLWorker.ParseToList(stringReader, null); shows null reference, but stringReader has content needed
HTMLWorker.ParseToList(stringReader, styles)but in your error message you haveHTMLWorker.ParseToList(stringReader, null). Which one is your actual code? Also, if you post a stack trace we might be able to help you more.