Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
protected void ImagePdf_Click(object sender, ImageClickEventArgs e)
    {
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=Files.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        div1.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();
    }
Posted
Updated 9-Jun-15 23:59pm
v3
Comments
Kornfeld Eliyahu Peter 10-Jun-15 4:31am    
Nice code...What is your question?
mrprakash 10-Jun-15 5:07am    
pnlPerson.RenderControl(hw);

here pnlperson inner text="" found
Kornfeld Eliyahu Peter 10-Jun-15 5:10am    
CCC is in the Lounge (and OG solved it already)...
mrprakash 10-Jun-15 5:15am    
error after using this code
Kornfeld Eliyahu Peter 10-Jun-15 5:18am    
If you adding information drop-by-drop you will have a solution in the next decade!!!
What error?

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