|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
String htmlText = html.ToString(); Document document = new Document(); string filePath = HostingEnvironment.MapPath("~/Content/Pdf/"); PdfWriter.GetInstance(document, new FileStream(filePath + "\\pdf-"+Name+".pdf", FileMode.Create)); document.Open(); iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document); FontFactory.Register(Path.Combine(_webHelper.MapPath("~/App_Data/Pdf/arial.ttf")), "Garamond"); // just give a path of arial.ttf StyleSheet css = new StyleSheet(); css.LoadTagStyle("body", "face", "Garamond"); css.LoadTagStyle("body", "encoding", "Identity-H"); css.LoadTagStyle("body", "size", "12pt"); hw.SetStyleSheet(css); hw.Parse(new StringReader(htmlText)); |
You should have a look at my another post about Caching In Asp.Net MVC
If you have question do not forget to write from the chat button next to it or from the comment.
