3
Answers

Error while Convert Aspx page to pdf file

Sameer Khan

Sameer Khan

9y
707
1
Error is : Extender control 'CalendarExtender1' is not a registered extender control.
 Extender controls must be registered using RegisterExtenderControl()
 before calling RegisterScriptDescriptors().Parameter name: extenderControl
Code is

Hide Copy Code
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
  StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
from here an Exception is thrown --> this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0.0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();

Answers (3)