将pdf附加到meteor中的电子邮件中

时间:2017-09-20 20:02:30

标签: pdf meteor

此Meteor服务器代码尝试附加pdf文件,但在服务器启动时出错。我想先避免在本地保存文件。 它使用pascoual:pdfkit。
我得到的错误是:

  

错误:消息失败:421超时等待来自客户端的数据。

Meteor doc指向 mailcomposer documentation,但问题是如何将pdf doc集成到附件中。有任何想法吗?感谢

Meteor.startup(() => {
  Invoice.email();
};

// invoice.js
use strict";
let PDFDocument = require ('pdfkit');
let metaData = {
  'Title': 'Invoice',
  'Author': 'myName',
};
export const Invoice = {
  'make': function () {
    let doc = new PDFDocument(metaData);
    doc.text('my company').text('company number');

    return doc;
  },
  'email': function () {
    let inv = Invoice.make();
    Email.send({
      to: 'myemail@comp.com',
      from: 'personal@company.com',
      subject: 'Invoice',
      text: ' Please see the attached invoice',
      attachments: {
        filename: 'invoice.pdf',
        content: inv // <=== this is the issue
     });
  }
};

1 个答案:

答案 0 :(得分:0)

根据文档,content定义为

  

内容 - 附件的字符串,缓冲区或流内容

链接到mailcomposer documentation.

如果我没有错,Invoice.make()没有返回期望的blob格式。请检查Stream并输入,以便您了解自己正在创建的内容。

链接到更多Supporting details

相关问题