node.js - How to use pdf output of PDFMake in the attachment mail options of NodeMailer? -


here 1 of pdfmake's code snippet create pdf file:

var pdfdoc = printer.createpdfkitdocument(docdefinition); pdfdoc.pipe(fs.createwritestream('pdfs/absolute.pdf')); pdfdoc.end(); 

and here 1 of attachment option in nodemailer:

{   // stream attachment   filename: 'text4.txt',   content: fs.createreadstream('file.txt') } 

i able create pdf , save file in directory , attach saved file in e-mail i want directly send output of pdf attachment content of e-mail without saving pdf output file.

i tried understand nodejs pipe , stream features couldn't understand them meet requirement. think should possible through stream , pipe don't know how achieve.

i want prevent saving of pdf output file because there can multiple users using functionality of creating pdf file , sending e-mail. there can situation when pdf file created 1 user overwritten user.

you instead of pipe, pass entire pdfdoc attachment

var pdfdoc = printer.createpdfkitdocument(docdefinition);  pdfdoc.end(); 

and then:

attachments: {     // stream attachment     filename: 'text4.pdf',     content: pdfdoc } 

Comments

Popular posts from this blog

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -