Click here to Skip to main content
15,039,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a sharepoint page in that there are so many visual webparts and page viewer webparts with vertical scrolling bar(in pageviwer webpart). My requirement is to convert this entire page contents including scrolling information to PDF by clicking on button in Visual Webpart. How can I do this, any help would be much appreciated. Using the below code I can convert the asp.net page to pdf but while I am integrating the same code in visual webpart, its failing in "VerifyRenderingInServerForm" message:This method cannot be found hence cannot be overrirden.

public override void VerifyRenderingInServerForm(Control control)
{
// /* Confirms that an HtmlForm control is rendered for the specified ASP.NET // server control at run time. */
}


protected void btnPDFGenerate_Click(object sender, EventArgs e)
{
try
{
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf"); HttpContext.Current.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, 10f, 10f, 100f, 0.0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
HttpContext.Current.Response.Write(pdfDoc);
HttpContext.Current.Response.End();


}
catch (Exception exp)
{


}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900