Monday, 6 February 2017

PRINT WEB PAGE IN PDF USING JAVASCRIPT IN ASP.NET C#

By using this function, can print page which is reside in any table. This method will print all things in PDF format.


<script language="javascript" type="text/javascript">

function PrintPageDetail() {

var printContent = document.getElementById('<%= tblGrd.ClientID %>');// TableName 
var printWindow = window.open("All Records", "Print Panel",     'left=50000,top=50000,width=0,height=0');
printWindow.document.write(printContent.innerHTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();

}

</script>

Call above function like this:

<asp:Button ID="btnPrint" runat="server" Text="Print Record(s)" OnClientClick="PrintPageDetail()"/>