Good Morning Friends,
I have a employee's salary database and i have designed salary slip in web form and displaying data in that form from data base.
When i am exporting the form to pdf it is only exporting the HTML content only, not the data which i have fetched from data base(using show button)
can anyone give me an idea how to export the web form data to pdf(as it is displayed in web form).
my code
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
Gowtham RajamanickamPosted May 28, 2015, 10:39 AM
Upendra Pratap ShahiPosted May 29, 2015, 12:38 AM
kuldeep singhPosted May 28, 2015, 11:52 PM
kuldeep singhPosted May 28, 2015, 11:49 PM
Gowtham RajamanickamPosted May 28, 2015, 10:38 AM
Gowtham RajamanickamPosted May 28, 2015, 10:38 AM
kuldeep singhPosted May 28, 2015, 9:32 AM
kuldeep singhPosted May 28, 2015, 4:27 AM
kuldeep singhPosted May 28, 2015, 3:59 AM
Upendra Pratap ShahiPosted May 28, 2015, 3:31 AM
Sanjeeb LenkaPosted May 28, 2015, 3:29 AM
Nanhe SiddiquePosted May 28, 2015, 3:27 AM
kuldeep singhPosted May 28, 2015, 3:26 AM
Hema LathaPosted May 28, 2015, 3:23 AM
kuldeep singhPosted May 28, 2015, 3:21 AM
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%--<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation = "false" %>--%>
DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Salary Sliptitle>
<style type="text/css">
#form1 {
height: 1068px;
}
style>
head>
<body>
<div id="dvText" runat="server">
<form id="form1" runat="server">
<asp:Button ID="btnExportToPdf" runat="server" OnClick="btnExportToPdf_Click" Text="Export" />
<asp:Button ID="btnView" runat="server" OnClick="btnView_Click" Text="View" />
<asp:Panel ID="Panel1" runat="server" Height="78px" style="margin-left: 349px" Width="456px">New Delhiasp:Panel>
<br />
<br />
<asp:Panel ID="Panel2" runat="server" Height="430px" style="margin-left: 0px" Width="802px">
<asp:Label ID="Label2" runat="server" Text="Employee Name">asp:Label>
<asp:DropDownList ID="ddlEmployeeName" runat="server" OnSelectedIndexChanged="ddlEmployeeName_SelectedIndexChanged">
asp:DropDownList>
<asp:Label ID="Label3" runat="server" Text="Month">asp:Label>
<asp:DropDownList ID="ddlMonth" runat="server" OnSelectedIndexChanged="ddlMonth_SelectedIndexChanged">
asp:DropDownList>
<br />
<asp:Label ID="Label4" runat="server" Text="Employee Designation">asp:Label>
<asp:TextBox ID="txtDesignation" runat="server">asp:TextBox>
<br />
<br />
<asp:Label ID="Label5" runat="server" Text="Salary Slip">asp:Label>
<br />
<asp:Label ID="Label6" runat="server" Text="EARNING">asp:Label>
<asp:Label ID="Label7" runat="server" Text="DEDUCTION">asp:Label>
<br />
<br />
<asp:Label ID="Label8" runat="server" Text="Particulars">asp:Label>
<asp:Label ID="Label9" runat="server" Text="Amount">asp:Label>
<asp:Label ID="Label10" runat="server" Text="Particulars">asp:Label>
<asp:Label ID="Label11" runat="server" Text="Amount">asp:Label>
<br />
<asp:Label ID="Label12" runat="server" Text="Basic">asp:Label>
<asp:TextBox ID="txtBasic" runat="server">asp:TextBox>
<asp:Label ID="Label13" runat="server" Text="Loan">asp:Label>
<asp:TextBox ID="txtLoan" runat="server">asp:TextBox>
<br />
<br />
<asp:Label ID="Label14" runat="server" Text="HRA">asp:Label>
<asp:TextBox ID="txtHRA" runat="server">asp:TextBox>
<asp:Label ID="Label15" runat="server" Text="Advance">asp:Label>
<asp:TextBox ID="txtAdvance" runat="server">asp:TextBox>
<br />
<br />
<asp:Label ID="Label16" runat="server" Text="Special Allowance">asp:Label>
;
<asp:TextBox ID="txtSAllowance" runat="server">asp:TextBox>
<asp:Label ID="Label17" runat="server" Text="PF">asp:Label>
<asp:TextBox ID="txtPF" runat="server">asp:TextBox>
<br />
<br />
<asp:Label ID="Label18" runat="server" Text="TA">asp:Label>
<asp:TextBox ID="txtTA" runat="server">asp:TextBox>
<asp:Label ID="Label19" runat="server" Text="TDS">asp:Label>
<asp:TextBox ID="txtTDS" runat="server">asp:TextBox>
<br />
<br />
<asp:Label ID="Label20" runat="server" Text="Variable Allowance">asp:Label>
;
<asp:TextBox ID="txtVAllowance" runat="server">asp:TextBox>
<asp:Label ID="Label21" runat="server" Text="Other Deduction">asp:Label>
<asp:TextBox ID="txtOtherDeduction" runat="server">asp:TextBox>
<br />
<br />
<asp:Label ID="Label22" runat="server" Text="Child Allowance">asp:Label>
<asp:TextBox ID="txtCAllowance" runat="server">asp:TextBox>
<br />
<br />
<br />
<br />
<br />
asp:Panel>
<br />
<br />
<asp:Panel ID="Panel5" runat="server" style="margin-left: 0px" Width="814px">
<asp:Label ID="Label23" runat="server" Text="Total">asp:Label>
<asp:TextBox ID="txtEarningTotal" runat="server">asp:TextBox>
<asp:Label ID="Label24" runat="server" Text="Total">asp:Label>
<asp:TextBox ID="txtDeducationTotal" runat="server">asp:TextBox>
<br />
<br />
<asp:Label ID="Label25" runat="server" Text="Net Salary(Figure) :-">asp:Label>
<asp:TextBox ID="txtNetSalary" runat="server" Width="602px">asp:TextBox>
<br />
<br />
<asp:Label ID="Label26" runat="server" Text="Net Salary(Words) :-">asp:Label>
<asp:TextBox ID="txtNetSalaryW" runat="server" Width="596px">asp:TextBox>
<br />
<br />
<br />
asp:Panel>
<br />
<br />
<br />
<br />
<asp:Label ID="Label27" runat="server" Text="For Breakthrough Trust">asp:Label>
<br />
<br />
<asp:Label ID="Label28" runat="server" Text="Sr. Manager Account">asp:Label>
<br />
<br />
<asp:Label ID="Label29" runat="server" Text="Date">asp:Label>
<asp:TextBox ID="txtDate" runat="server">asp:TextBox>
<br />
<br />
<asp:Label ID="Label30" runat="server" Text="Place">asp:Label>
<asp:TextBox ID="txtPlace" runat="server">asp:TextBox>
form> div>
body>
html>
kuldeep singhPosted May 28, 2015, 3:13 AM
kuldeep singhPosted May 28, 2015, 3:12 AM
Upendra Pratap ShahiPosted May 28, 2015, 3:10 AM
Sanjeeb LenkaPosted May 28, 2015, 2:55 AM