我正在使用面板控制中的一个静态表,如何将面板内的 html 内容转换为 pdf,请在单击按钮导出后立即帮助我转换为 pdf
Aspx 代码:-
<table width="100%">
<tr>
<td>
<asp:Panel ID="pnlPerson" runat="server">
<table border="1" style="font-family: Arial; font-size: 10pt; width: 200px">
<tr>
<td colspan="2" style="background-color: #18B5F0; height: 18px; color: White; border: 1px solid white">
<b>Personal Details</b>
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<asp:Label ID="lblName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<b>Age:</b>
</td>
<td>
<asp:Label ID="lblAge" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<b>City:</b>
</td>
<td>
<asp:Label ID="lblCity" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<b>Country:</b>
</td>
<td>
<asp:Label ID="lblCountry" runat="server"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
<asp:Button ID="btnExport" runat="server" Text="Export" />
</td>
</tr>
</table>
C#.net 代码:-
if (!IsPostBack)
{
//Populate DataTable
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Age");
dt.Columns.Add("City");
dt.Columns.Add("Country");
dt.Rows.Add();
dt.Rows[0]["Name"] = "Mudassar Khan";
dt.Rows[0]["Age"] = "27";
dt.Rows[0]["City"] = "Mumbai";
dt.Rows[0]["Country"] = "India";
//Bind Datatable to Labels
lblName.Text = dt.Rows[0]["Name"].ToString();
lblAge.Text = dt.Rows[0]["Age"].ToString();
lblCity.Text = dt.Rows[0]["City"].ToString();
lblCountry.Text = dt.Rows[0]["Country"].ToString();
}
protected void btnExport_Click(object sender, EventArgs e)
{
}
请务必向我发送此导出按钮的 C# 代码