<script type='text/javascript' src='http://code.jquery.com/jquery-2.1.3.js'></script>
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>
<script type="text/javascript">
$(window).load(function(){
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
$('#cmd').click(function () {
doc.fromHTML($('#content').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
});
});
</script>
当我点击生成pdf按钮时,pdf文件正在下载,但图像没有显示。
<div id="content">
<img src="file:///C:/Users/lakshmi_priya/Desktop/datepicker.png" width="100" height="100" />asfasdfasdfasdsfsdfasdfasdfasdfa
</div>
<div id="editor"></div>
<button id="cmd">generate PDF</button>
</body>