Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将jsPDF输出附加到mailto_Javascript_Php_Email Attachments_Jspdf_Mailto - Fatal编程技术网

Javascript 如何将jsPDF输出附加到mailto

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

我正在使用jsPDF将HTML表转换为PDF。我想获取PDF,然后单击按钮将其附加到
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的表格。

检查此项-该“可能重复”的可能重复仅是实际问题的一半。