HTML转换为PDF
<html>
<head>
<title><title>
</head>
<body>
<div><buttion id='btn_htmlToPdf'></buttion></div>
<div id="content">
<ul>
<li>Are you going to Scarborough Fair </li>
<li>Are you going to Scarborough Fair </li>
<li>Are you going to Scarborough Fair </li>
<li>Are you going to Scarborough Fair </li>
<li>Are you going to Scarborough Fair </li>
</ul>
</div>
</body>
<script src="js/jspdf.degug.js"></script>
<script src="js/html2canvas.js"></script>
<script src="js/JQuer,min.js"></script>
<script>
$("#btn_htmlToPdf").click(funciton(){
//获取要截取为图片的地方
html2canvas($("#content"),
{
//渲染完成时调用,获取canvas
onrendered:function(canvas){
//从canvas 提取图片资源
var imageData=canvas.toDataURL("image/jpeg");
var doc=new jsPDF("p","mm","a4")
doc.addImage(imageData,'JPEG',0,0,210,297);
doc.save('content.pdf')
}
}
)
})
</script>
</html>