Hi,
Can anyone tell me how to convert a PDF document from an HTML code using C#? I'm using itextsharp 5.0.2 dll. I have come across this forum. I didnt find any solution so far. And some of them mentioned iTextSharp.HtmlParser but i cannot find such kind of class in my version of dll. In which version should i need to use to achieve my task.
I have tried with this code...i dont know what wrong did i do? Im not getting the PDF file.
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestResult.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringBuilder htmlText =
new StringBuilder("<table style='color:red;' border='1'>");
htmlText.Append("<tr><th>Karunagara Pandi</th><tr><td> Software Engineer</td></tr></table>");
StringReader stringReader = new StringReader(htmlText.ToString());
Document doc = new Document(PageSize.A4);
List<iTextSharp.text.IElement> elements =
iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(stringReader, null);
doc.Open();
foreach (object item in elements)
{
doc.Add((IElement)item);
}
// Response Output
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
//doc.Close();
Response.Write("PDF is created");
This code also taken from this site only....I need to your proper solution. I'll also try to get.....
Thanks.