Created
March 5, 2018 13:51
-
-
Save MdKutubuddinSardar/16ad61c7be5161b9d72144454b012392 to your computer and use it in GitHub Desktop.
Generate pdf from HTML foem in div using Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title></title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$("#btnPrint").live("click", function () { | |
var divContents = $("#dvContainer").html(); | |
var printWindow = window.open('', '', 'height=400,width=800'); | |
printWindow.document.write('<html><head><title>DIV Contents</title>'); | |
printWindow.document.write('</head><body >'); | |
printWindow.document.write(divContents); | |
printWindow.document.write('</body></html>'); | |
printWindow.document.close(); | |
printWindow.print(); | |
}); | |
</script> | |
</head> | |
<body> | |
<form id="form1"> | |
<div id="dvContainer"> | |
This content needs to be printed. | |
</div> | |
<input type="button" value="Print Div Contents" id="btnPrint" /> | |
</form> | |
</body> | |
</html> |
This is the simple solution. This works for me.You can use the javascript print concept and simple save this as pdf
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/MrRio/jsPDF