Change file name of toStream() in node.js html-pdf npm module -


i trying change file name of pdf generated npm module html-pdf.

the issue do not want save copy of pdf, stream email service ( mailgun) , send off. have working when receive email file has default name want change. have experience trying this?

thanks

var pdf = require('html-pdf'); var mailgun = require('mailgun-js');  pdf.create(result).tostream(function(err, stream) {     var self = this;     if (err) return console.log(err);      //set mailgun parameters      var mail_data = {         from: 'emailtosendto@email.com',         to: 'sendingemail@email.com',         subject: 'subject line',         html: result,         attachment: stream     }     //send email     mailgun.messages().send(mail_data, function (err, body) {         if (err) {             res.render('error', { error : err});             console.log("got error: ", err);         }         else {             console.log(body);             res.send('ok');         }     });  }); 

var pdf = require('html-pdf'); var mailgun = require('mailgun-js');  pdf.create(result).tobuffer(function(err, buffer) {     var self = this;     if (err) return console.log(err);      var attch = new mailgun.attachment({data: buffer, filename: 'myattach.pdf'});      //set mailgun parameters      var mail_data = {         from: 'emailtosendto@email.com',         to: 'sendingemail@email.com',         subject: 'subject line',         html: result,         attachment: attch     }     //send email     mailgun.messages().send(mail_data, function (err, body) {         if (err) {             res.render('error', { error : err});             console.log("got error: ", err);         }         else {             console.log(body);             res.send('ok');         }     });  }); 

from https://github.com/bojand/mailgun-js#attachments


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -