santosh kumar

santosh kumar

  • 1.9k
  • 22
  • 3.2k

Converting Asp.net Webpage to PDF using Itextsharp

Jan 20 2018 2:52 PM
I get the below error while converting asp.net webpage to pdf
 
Script control 'UpdateProgress1' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
 
Code behind file as below:
 
protected void btnExport_Click(object sender, EventArgs e)
{
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);(Exception occurs here)
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
 
Attached the codebehind and aspx pages.
 
Request you to help me in finding the sloution 
 
Thanks and Regards,
Santosh Kumar 
 

Attachment: TicketDetail.zip

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (10)