I found this using google ("itextsharp htmlparser") at the following link. How many times do we have to tell people that google should be ther FIRST thing you should use to find an answer to your questions?
http://forums.asp.net/t/1199774.aspx[
^]
---------------------------------
I got itextsharp version 4.1.6.0 and got it to work like this for parsing html not in a file...:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Collections;
using System.Text;
using iTextSharp.text.xml;
using iTextSharp.text.html;
public partial class itexttest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Document document = new Document();
try {
PdfWriter.GetInstance(document, new FileStream(Server.MapPath("/") + "WordDoc/" + "parsetest.pdf", FileMode.Create));
document.Open();
String htmlText="<font hold=" />" color="\"#0000FF\"">Title One</font><font hold=" />" color="\"black\""><br><br>Some text here<br><br><br><font hold=" />" color="\"#0000FF\"">Another title here " +
" </font><font hold=" />" color="\"black\""><br><br>Text1<br>Text2<br><ol><li>hi</li><li>how are u</li></ol>";
//make an arraylist ....with STRINGREADER since its no IO reading file...
ArrayList htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
//add the collection to the document
for (int k = 0; k < htmlarraylist.Count; k++)
{
document.Add((IElement)htmlarraylist[k]);
}
document.Add(new Paragraph("And the same with indentation...."));
// or add the collection to an paragraph
// if you add it to an existing non emtpy paragraph it will insert it from
//the point youwrite -
Paragraph mypara = new Paragraph();//make an emtphy paragraph as "holder"
mypara.IndentationLeft = 36;
mypara.InsertRange(0, htmlarraylist);
document.Add(mypara);
document.Close();
}
catch (Exception exx) {
Console.Error.WriteLine(exx.StackTrace);
Console.Error.WriteLine(exx.Message);
}
}
}</br></br></br></br></font></br></br></br></br></br></font>