Javascript 如何将jsPDF输出附加到mailto
我正在使用jsPDF将HTML表转换为PDF。我想获取PDF,然后单击按钮将其附加到Javascript 如何将jsPDF输出附加到mailto,javascript,php,email-attachments,jspdf,mailto,Javascript,Php,Email Attachments,Jspdf,Mailto,我正在使用jsPDF将HTML表转换为PDF。我想获取PDF,然后单击按钮将其附加到mailto中的电子邮件中 有人能帮我吗?下面是我使用jsPDF获取PDF的代码。我使用了jsPDF的output()函数,它是PDF的base64字符串。根据mailto的语法,附件应该是要附加的文件的路径。因此,我可以告诉你如何临时存储PDF,使用电子邮件路径,然后从临时位置删除文件。我不知道怎么做。有人能帮我吗 function funcEmail() { pdf = new jsPDF('p', 'p
mailto
中的电子邮件中
有人能帮我吗?下面是我使用jsPDF获取PDF的代码。我使用了jsPDF的output()
函数,它是PDF的base64字符串。根据mailto
的语法,附件应该是要附加的文件的路径。因此,我可以告诉你如何临时存储PDF,使用电子邮件路径,然后从临时位置删除文件。我不知道怎么做。有人能帮我吗
function funcEmail() {
pdf = new jsPDF('p', 'pt', 'letter');
source = $('#print_preview')[0];
specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#bypassme': function(element, renderer) {
// true = "handled elsewhere, bypass text extraction"
return true
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
// all coords and widths are in jsPDF instance's declared units
// 'inches' in this case
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
//pdf.save('Test.pdf');
emailPdf = pdf.output('datauristring');
}, margins);
//console.log(dataurl);
//console.log(emailPdf);
location.href = "mailto:mail@example.org?subject=Test&body=Test&attachments='+emailPdf+'";
}
这就是我到目前为止所尝试的。这里,print\u preview
是id
到div
的,包含要转换为PDF的表格。检查此项-该“可能重复”的可能重复仅是实际问题的一半。