public string HTMLToPdf(_TableProperty ReportProperty, string FilePath,Stream stream) { string htmlread2 = getReportHTML(ReportProperty, stream); Document document = new Document(); PdfWriter.GetInstance(document, new FileStream(System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "C:\\HRMS OSN\\latest\\HRMS\\admpanel\\myPDF.pdf", FileMode.Create)); document.Open(); iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(System.Web.HttpContext.Current.Server.MapPath("pdfic.jpg")); pdfImage.ScaleToFit(100, 50); pdfImage.Alignment = iTextSharp.text.Image.UNDERLYING; pdfImage.SetAbsolutePosition(180, 760); document.Add(pdfImage); iTextSharp.text.html.simpleparser.StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet(); iTextSharp.text.html.simpleparser.XHTMLWorker hw = new iTextSharp.text.html.simpleparser.XHTMLWorker(document); hw.Parse(new StringReader(htmlread2)); document.Close(); ShowPdf("C:\\HRMS OSN\\latest\\HRMS\\admpanel\\myPDF.pdf"); return htmlread2; } private void ShowPdf(string s) { System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.ClearHeaders(); System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + s); System.Web.HttpContext.Current.Response.ContentType = "application/pdf"; System.Web.HttpContext.Current.Response.WriteFile(s); System.Web.HttpContext.Current.Response.Flush(); System.Web.HttpContext.Current.Response.Clear(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)