Converting Asp.net Webpage to PDF using Itextsharp

Posted by Dantenan under ASP.NET on 1/21/2018 | Points: 10 | Views : 486 | Status : [Member] | Replies : 1
I get the below error while converting asp.net webpage to pdf using ItextSharp

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();
}

PFA of the codebehind and aspx page.

Request you to help in fixing this issue




Responses

Posted by: Self-Innovator on: 1/24/2018 [Member] Bronze | Points: 25

Up
0
Down
Try this link http://www.dotnetfunda.com/articles/show/2175/how-to-convert-gridview-data-in-to-pdf-file

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Dantenan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response