I use iTextSharp to convert HTML to PDF, overall it works pretty well, but it doesn't seem to be like most formatting.
Bold, Italic, and Underline work, but none of the font sizes, styles, or other information is respected, so the export does not look very similar to the HTML that was used to create the format.
Does anybody know how
- fix iTextSharp export method (below is an example of my code)
- Or find out about another product that exists that provides this functionality and won't break the bank?
This is my code:
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();
}
source
share