Skip to content
Loading
How to Download Panel Data in PDF File Format  
  •   
  • class="container margintop70">  
  • "pnlSignUp" runat="server">  
  • class="col-lg-3">  
  •   
  • class="col-lg-8 margintop40 margin-bottom20 margintop40 pull-left" style="width: 45%">  
  • class="panel">  
  • class="panel-body panel-content">  
  • class="col-lg-12 margintop20">  
  •   

  • Get Certificate  
  • Continue with tallyelearning.com  
  •   
  •   
  • class="fulldiv col-lg-12">  
  • class="form-group fulldiv margintop20">  
  • class="col-lg-12 noleftpadding">  
  • First Name  
  • "txtFirstName" runat="server" CssClass="form-control" MaxLength="50"  
  • onblur="validateFirstName(this,'txtFirstName');">  
  •   
  • class="col-lg-12 margintop10 noleftpadding">  
  • Last Name  
  • "txtLastName" runat="server" CssClass="form-control" MaxLength="50"  
  • onblur="validateLastName(this,'txtLastName');">  
  •   
  •   
  • class="form-group fulldiv margintop20">  
  • class="col-lg-12 margintop10 noleftpadding">  
  • Email Id  
  • "txtEmailId" runat="server" CssClass="form-control" MaxLength="100"  
  • onblur="validateEmail(this,'txtEmailId');">  
  •   
  • class="col-lg-12 margintop10 noleftpadding">  
  • Contact No  
  • "txtContact" runat="server" CssClass="form-control" MaxLength="10"  
  • onblur="return ValidateMobNumber('txtContact')">  
  •   
  •   
  • class="fulldiv pull-left text-center margintop30 margin-bottom20">  
  • "lnkSignUp" OnClick="lnkSignUp_Click" runat="server" OnClientClick="return CheckBlank()"  
  • CssClass="btn btn-theme flatbtn" Width="280px" Height="40px" Font-Size="15px"  
  • Style="padding-top: 10px">class="fa fa-file-pdf-o"> Generate Certificate  
  •   
  •   
  •   
  •   
  •   
  •   
  • class="col-lg-12 margintop10">  
  • class="col-lg-3">  
  •   
  • "divPanel" runat="server" class="col-lg-5" style="font-family: Times New Roman;  
  • font-style: italic; font-size: 17px">  
  • "pnlCertificate" runat="server">  
  • class="">  
  • class="bg-white margintop10 fulldiv">  
  • class="text-center">  
  • "Student/Images/1.jpg" width="100%" />  
  •   
  • class="text-center">  
  • This certificate is proudly presented to  
  •   
  • class="text-center margin-bottom10">  
  • "lblName" runat="server" Font-Bold="true" Font-Size="22px" CssClass="firebricktext text-capitalize">  
  •   
  • class="text-center margin-bottom10 margintop10">  
  • Successfully completed in  
  • "lblCourseName" CssClass="text-capitalize" runat="server" Font-Bold="true"  
  • Font-Size="22px">  
  •   
  • class="text-center margintop10">  
  • At Authorized training center  
  •   
  • class="text-center margin-bottom10">  
  • "lblTrainingCenter" CssClass="text-capitalize" runat="server" Font-Bold="true">  
  •   
  • class="text-center margin-bottom10 margintop10">  
  • He/She has awarded this certificate for distinctive  
  • performance in this programme  
  •   
  • "margin-top: 30px; margin-bottom: -71px; float: left; width: 100%">  
  • class="margin-bottom10 margintop10">  
  • class="col-lg-5">  
  • Grade :  
  • "lblGrade" runat="server">  
  •   
  • class="col-lg-5 pull-right">  
  • Date of Issue :  
  • "lblDateofIssue" runat="server">  
  •   
  •   
  • class="margin-bottom10 margintop10 fulldiv pull-left">  
  • class="col-lg-10">  
  • Certificate No :  
  • "lblCertificateNo" runat="server" Font-Size="18px">  
  •   
  • class="col-lg-1">  
  •   
  •   
  •   
  • class="text-center">  
  • "Student/Images/21.jpg" width="100%" />  
  •   
  •   
  •   
  •   
  •   
  • class="col-lg-4">  
  •   
  • class="col-lg-12 margintop10">  
  • class="col-lg-2">  
  •   
  • class="col-lg-7 text-center">  
  • "lnkPrintPDF" OnClick="lnkPrintPDF_Click" runat="server" CssClass="btn btn-theme"  
  • Visible="false" OnClientClick="printDiv('divPanel')"> Print PDF   
  •   
  • class="col-lg-3">  
  •   
  •   
  •   
  •   
  •   
  •   
  •   
  • AND
     
    Here is MY Code Behind On Button Click Event
    1. protected void lnkPrintPDF_Click(Object sender, EventArgs e)  
    2. {  
    3. Response.Clear();  
    4. Response.Buffer = true;  
    5. Response.ClearContent();  
    6. Response.ClearHeaders();  
    7. Response.Charset = "";  
    8. string FileName = "Tally Certificate" + DateTime.Now + ".pdf";  
    9. StringWriter sw = new StringWriter();  
    10. HtmlTextWriter hw = new HtmlTextWriter(sw);  
    11. Response.Cache.SetCacheability(HttpCacheability.NoCache);  
    12. Response.ContentType = "application/pdf";  
    13. Response.AddHeader("Content-Disposition""attachment;filename=" + FileName);  
    14. pnlCertificate.Visible = true;  
    15. pnlCertificate.RenderControl(hw);  
    16. Response.Write(sw.ToString());  
    17. Response.End();  
    18. }  
    So in this Button Click I am downlaod the file but when i open that pdf file i am getting error like Adobe Reader Can not open the file because it is either not a supported file type or because the file has been damaged. So, Please anyone tell me the solution.

    1 Reply

    Know the answer? Post it — somebody with the same question will find it here.