Adhikar Patil

Adhikar Patil

  • NA
  • 481
  • 128.4k

How to Get As it is Certificate in C#

May 4 2018 6:02 AM
Hi,
 
This is My Aspx code and below is my c# code i am getting certificate but it comes with design issues. the images in certificate not coming in proper formats.
  1. <asp:Panel ID="pnlCertificate" runat="server">  
  2. <div style="width: 1170px; padding-right:15px; padding-left:15px; margin-right:auto; margin-left:auto">  
  3. <div class="col-lg-12 margintop10" style="margin-top: 10px; width: 100%; height:auto">  
  4. <div class="col-lg-3" style="width: 25%">  
  5. </div>  
  6. <div id="divPanel" runat="server" class="col-lg-5" style="font-family: Times New Roman;  
  7. font-style: italic; font-size: 17px; width: 41.66666667%;">  
  8. <%-- <div class="">--%>  
  9. <div class="bg-white margintop10 fulldiv" style="background-color: White; margin-top: 10px; width: 100%">  
  10. <div class="text-center" style="text-align: center;width: 100%; " >  
  11. <center>  
  12. <img src="http://tallyelearning.com/Student/Images/1.jpg" width="100%" alt="img" />  
  13. </center>  
  14. </div>  
  15. <div class="text-center" style="text-align: center;width: 100%">  
  16. This certificate is proudly presented to  
  17. </div>  
  18. <div class="text-center margin-bottom10" style="text-align: center; margin-bottom: 10px;width: 100%">  
  19. <asp:Label ID="lblName" runat="server" Font-Bold="true" Font-Size="22px" CssClass="firebricktext text-capitalize" style="text-transform:capitalize; color:firebrick;"></asp:Label>  
  20. </div>  
  21. <div class="text-center margin-bottom10 margintop10" style="text-align: center; margin-bottom: 10px; margin-top:10px;width: 100%">  
  22. Successfully completed in<br />  
  23. <asp:Label ID="lblCourseName" CssClass="text-capitalize" runat="server" Font-Bold="true" style="text-transform:capitalize"  
  24. Font-Size="22px"></asp:Label>  
  25. </div>  
  26. <div class="text-center margintop10" style="text-align: center; margin-top: 10px; width: 100%">  
  27. <span>At Authorized training center</span>  
  28. </div>  
  29. <div class="text-center margin-bottom10" style="text-align: center; margin-bottom: 10px; width: 100%">  
  30. <asp:Label ID="lblTrainingCenter" CssClass="text-capitalize" style="text-transform:capitalize" runat="server" Font-Bold="true"></asp:Label>  
  31. </div>  
  32. <div class="text-center margin-bottom10 margintop10" style="text-align: center; margin-bottom: 10px; margin-top:10px;width: 100%">  
  33. <label>  
  34. He/She has awarded this certificate for distinctive<br />  
  35. performance in this programme</label>  
  36. </div>  
  37. <div style="margin-top: 30px; margin-bottom: -71px; float: left; width: 100%">  
  38. <div class="margin-bottom10 margintop10" style="margin-bottom: 10px; margin-top:10px;width: 100%">  
  39. <div class="col-lg-6" style="width:50%">  
  40. Grade :  
  41. <asp:Label ID="lblGrade" runat="server"></asp:Label>  
  42. </div>  
  43. <div class="col-lg-6 pull-right" style="width:50%; float:right">  
  44. Date of Issue :  
  45. <asp:Label ID="lblDateofIssue" runat="server"></asp:Label>  
  46. </div>  
  47. </div>  
  48. <div class="margin-bottom10 margintop10 fulldiv pull-left" style="margin-bottom: 10px; margin-top:10px; width:100%; float:left">  
  49. <div class="col-lg-10" style="width: 83.33333333%">  
  50. Certificate No :  
  51. <asp:Label ID="lblCertificateNo" runat="server" Font-Size="18px"></asp:Label>  
  52. </div>  
  53. <div class="col-lg-1" style="width: 8.33333333%">  
  54. </div>  
  55. </div>  
  56. </div>  
  57. <div class="text-center" style="text-align:center">  
  58. <img src="http://tallyelearning.com/Student/Images/21.jpg" width="100%" alt="img1" />  
  59. </div>  
  60. </div>  
  61. <%-- </div>--%>  
  62. <%-- </asp:Panel>--%>  
  63. </div>  
  64. <div class="col-lg-4" style="width: 33.33333333%">  
  65. </div>  
  66. <div class="col-lg-12 margintop10">  
  67. <div class="col-lg-2">  
  68. </div>  
  69. <div class="col-lg-7 text-center">  
  70. <asp:LinkButton ID="lnkPrintPDF" OnClick="lnkPrintPDF_Click" runat="server" CssClass="btn btn-theme"  
  71. Visible="false"> Print PDF </asp:LinkButton>  
  72. <%-- <asp:LinkButton ID="lnkPrintPDF" OnClick="lnkPrintPDF_Click" runat="server" CssClass="btn btn-theme"  
  73. Visible="false" OnClientClick="printDiv('divPanel')"> Print PDF </asp:LinkButton>--%>  
  74. </div>  
  75. <div class="col-lg-3">  
  76. </div>  
  77. </div>  
  78. </div>  
  79. </div>  
  80. </asp:Panel>  
  1. public void DisplayCertificate()  
  2. {  
  3. int year = Convert.ToInt32(DateTime.Now.Year.ToString().Substring(2, 2));  
  4. int nextyear = year + 1;  
  5. string CertificateNo = "PMT" + "/" + 000 + "/" + year + "-" + nextyear;  
  6. lblName.Text = "Adhikar" + " " + "Patil";  
  7. lblCourseName.Text = "Tally.ERP 9 With GST";  
  8. lblTrainingCenter.Text = "Prompt Computer, Dhule";  
  9. lblDateofIssue.Text = System.DateTime.Now.ToString("dd/MM/yyyy");  
  10. lblCertificateNo.Text = CertificateNo;  
  11. lblGrade.Text = "A";  
  12. }  
  13. protected void lnkPrintPDF_Click(Object sender, EventArgs e)  
  14. {  
  15. //SendHTMLAttachment();  
  16. Response.ContentType = "application/pdf";  
  17. Response.AddHeader("content-disposition""attachment;filename=TallyCertificate.pdf");  
  18. Response.Cache.SetCacheability(HttpCacheability.NoCache);  
  19. divPanel.Visible = true;  
  20. StringWriter stringWriter = new StringWriter();  
  21. HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);  
  22. divPanel.RenderControl(htmlTextWriter);  
  23. using (MemoryStream ms = new MemoryStream())  
  24. {  
  25. StringReader stringReader = new StringReader(stringWriter.ToString());  
  26. Document Doc = new Document(PageSize.A4, 25, 25, 30, 30);  
  27. //Document Doc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);  
  28. HTMLWorker htmlparser = new HTMLWorker(Doc);  
  29. PdfWriter.GetInstance(Doc, Response.OutputStream);  
  30. Doc.Open();  
  31. htmlparser.Parse(stringReader);  
  32. Doc.Close();  
  33. Response.Write(Doc);  
  34. Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);  
  35. Response.End();  
  36. }

Answers (1)