Hi,
I am currently working on an Invoice System, but I am facing some difficulties while converting the webpage to PDF including Gridview & Image(s).
Normally I use the following codes to convert into pdf, but these codes are showing the error Input string was not in the correct format while including Gridview & Images in the webpage and are only converting the normal text.
Code :
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 0f, 0f, -70f, -40f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
I am expecting your reply eagerly
Regards
Sathik