1) design
<asp:Panel ID="pnlPerson" runat="server">
<table>
<tr>
<td>
<b style="font-size: 26px; float: right; color: #432b63;">Financial Summary</b>
<br />
</td>
<td>
</td>
</tr>
<tr>
<td>
<b>Client Name :</b>
</td>
<td>
<b>
<asp:Label ID="lblClient" runat="server"></asp:Label></b>
</td>
</tr>
<tr>
<td>
<b>Risk category :</b>
</td>
<td>
<asp:Label ID="lblriskcategory" runat="server"></asp:Label>
</td>
</tr>
</table>
<table style="width: 100%;">
<tr>
<td style="width: 23%;">
<b>Recommended Asset Classes : </b>
</td>
<td style="width: 77%; margin-left: -5px;">
<span style="margin-left: 14px;">
<asp:Label ID="lbldebt" runat="server"></asp:Label></span> <span>
<asp:Label ID="lblhybrid" runat="server"></asp:Label></span> <span>
<asp:Label ID="lblequity" runat="server"></asp:Label></span> <span>
<asp:Label ID="lblmultiasset" runat="server"></asp:Label></span>
<span>
<asp:Label ID="lblinternational" runat="server"></asp:Label></span>
</td>
</tr>
</table>
<!-- Added By Sanket For PDF Creation -->
<b style="margin-left: 2px;">Goal Summary </b>
<%-- <table width="60%" cellpadding="10" cellspacing="1" style="padding-top: 10px; margin-top: 10px;">
<tbody style="text-align: -webkit-center;">
<tr id="tdRetirement" runat="server" visible="false">
<td width="50%" bgcolor="#FCEBCF" class="text">
Retirement Goal
</td>
<td width="50%" bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblretirement" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdEducation" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Education Goal
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lbleducation" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdMarriage" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Marriage Goal
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblmarriage" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdInvestmentNeed" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Your Investment Need
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblneed" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdCurrentIncome" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Your Current Income
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblincome" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdMonthlyBalance" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Monthly Balance After Investments
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblresult" runat="server"></asp:Label>
</td>
</tr>
</tbody>
</table>--%>
<table width="90%" cellpadding="10" cellspacing="1" style="padding-top: 10px; margin-top: 10px;
height: auto;">
<%=getWhileLoopData() %>
<tr>
<td bgcolor="#FCEBCF" class="text">
Your Investment Need
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblinvestmentneed" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#FCEBCF" class="text">
Your Current Income
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblincome" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#FCEBCF" class="text">
Monthly Balance After Investments
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblresult" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="lblwarning" runat="server" Style="color: Red; font-weight: bold; float: right;"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</asp:Panel>
2) code
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Summary" + DateTime.Now.Date + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnlPerson.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
<asp:Panel ID="pnlPerson" runat="server">
<table>
<tr>
<td>
<b style="font-size: 26px; float: right; color: #432b63;">Financial Summary</b>
<br />
</td>
<td>
</td>
</tr>
<tr>
<td>
<b>Client Name :</b>
</td>
<td>
<b>
<asp:Label ID="lblClient" runat="server"></asp:Label></b>
</td>
</tr>
<tr>
<td>
<b>Risk category :</b>
</td>
<td>
<asp:Label ID="lblriskcategory" runat="server"></asp:Label>
</td>
</tr>
</table>
<table style="width: 100%;">
<tr>
<td style="width: 23%;">
<b>Recommended Asset Classes : </b>
</td>
<td style="width: 77%; margin-left: -5px;">
<span style="margin-left: 14px;">
<asp:Label ID="lbldebt" runat="server"></asp:Label></span> <span>
<asp:Label ID="lblhybrid" runat="server"></asp:Label></span> <span>
<asp:Label ID="lblequity" runat="server"></asp:Label></span> <span>
<asp:Label ID="lblmultiasset" runat="server"></asp:Label></span>
<span>
<asp:Label ID="lblinternational" runat="server"></asp:Label></span>
</td>
</tr>
</table>
<!-- Added By Sanket For PDF Creation -->
<b style="margin-left: 2px;">Goal Summary </b>
<%-- <table width="60%" cellpadding="10" cellspacing="1" style="padding-top: 10px; margin-top: 10px;">
<tbody style="text-align: -webkit-center;">
<tr id="tdRetirement" runat="server" visible="false">
<td width="50%" bgcolor="#FCEBCF" class="text">
Retirement Goal
</td>
<td width="50%" bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblretirement" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdEducation" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Education Goal
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lbleducation" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdMarriage" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Marriage Goal
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblmarriage" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdInvestmentNeed" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Your Investment Need
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblneed" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdCurrentIncome" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Your Current Income
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblincome" runat="server"></asp:Label>
</td>
</tr>
<tr id="tdMonthlyBalance" runat="server" visible="false">
<td bgcolor="#FCEBCF" class="text">
Monthly Balance After Investments
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblresult" runat="server"></asp:Label>
</td>
</tr>
</tbody>
</table>--%>
<table width="90%" cellpadding="10" cellspacing="1" style="padding-top: 10px; margin-top: 10px;
height: auto;">
<%=getWhileLoopData() %>
<tr>
<td bgcolor="#FCEBCF" class="text">
Your Investment Need
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblinvestmentneed" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#FCEBCF" class="text">
Your Current Income
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblincome" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#FCEBCF" class="text">
Monthly Balance After Investments
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblresult" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="lblwarning" runat="server" Style="color: Red; font-weight: bold; float: right;"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</asp:Panel>
2) code
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Summary" + DateTime.Now.Date + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnlPerson.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
No comments:
Post a Comment