这是我的代码,我正在尝试下载一个名为PDFContent的div,其中包含许多图像和文本。图片可以放入PDF生成的文件中,而文本则不能。
$(“#downloadManual”)。click(function(){ console.log(“正在生成PDF”)
var pdf = new jsPDF('p', 'pt', 'letter');
//var pdf = new jsPDF();
source = $('#PDFContent').html();
specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#bypassme' : function(element, renderer) {
// true = "handled elsewhere, bypass text extraction"
return true
}
};
margins = {
top : 5,
bottom : 60,
left : 10,
width : 700
};
pdf.fromHTML(source, // HTML string or DOM elem ref.
margins.left, // x coord
margins.top, { // y coord
'width' : margins.width, // max width of content on PDF
'elementHandlers' : specialElementHandlers
},
function(dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
headerFooterFormatting(pdf, pdf.internal.getNumberOfPages());
pdf.save('Test.pdf');
}, margins);
});//end of button click event