public void HTMLToPdf(string HTML, string contcss) { Byte[] bytes; using (var ms = new MemoryStream()) { using (var doc = new Document()) { using (var writer = PdfWriter.GetInstance(doc, ms)) { doc.Open(); var example_html = HTML; var example_css = contcss; using (var msCss = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(example_css))) { using (var msHtml = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(example_html))) { iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msHtml, msCss); } } doc.Close(); } } bytes = ms.ToArray(); } var testFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test1.pdf"); System.IO.File.WriteAllBytes(testFile, bytes); }>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)