I have been using iTextSharp to do a HTML to PDF conversion, overall it works fairly well, but it doesn't seem to be like most of the formatting.
Bold, Italic, and Underline are all working, however, none of the font sizes, styles or other information is respected, therefore the export doesn't look much at all like the HTML that was used to create the format.
Does anyone know how to either
- fix the way the iTextSharp exports (below is a sample of my code)
- Or know of a different product that is out there that provides this functionality, and will not break the bank?
This is my code:
//Do the PDF thing
Document document = new Document(PageSize.A4);
using (Stream output = new FileStream(Server.MapPath(relDownloadDoc), FileMode.Create, FileAccess.Write, FileShare.None))
using (Stream htmlStream = new FileStream(Server.MapPath(relProcessingDoc), FileMode.Open, FileAccess.Read, FileShare.Read))
using (XmlTextReader reader = new XmlTextReader(htmlStream))
{
reader.WhitespaceHandling = WhitespaceHandling.None;
PdfWriter.GetInstance(document, output);
document.Open();
Console.ReadLine();
HtmlParser.Parse(document, reader);
document.Close();
}