recently, I have an HTML file that is opened in an iframe. In the HTML file, there is some textbox so when the user fills the textbox then by click button, the HTML or iframe content will be saved as a pdf file.
What I have tried:
Response.ContentType = "Application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
StringWriter s_tw = new StringWriter();
HtmlTextWriter h_textw = new HtmlTextWriter(s_tw);
h_textw.AddStyleAttribute("font-size", "7pt");
h_textw.AddStyleAttribute("color", "Black");
myiframe.RenderControl(h_textw);//Name of the ifarme
Document doc = new Document();
doc = new Document(PageSize.A4, 50, 50, 40, 40);
FontFactory.GetFont("Times New Roman", 14);
//PdfWriter pdf = PdfWriter.GetInstance(doc, Response.OutputStream);
StringReader s_tr = new StringReader(s_tw.ToString());
HTMLWorker html_worker = new HTMLWorker(doc);
PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
doc.NewPage();
html_worker.Parse(s_tr);
doc.Close();
Response.Write(doc);
Response.End();