I am trying to create an application that will take an html file that is populated using a jquery request. I am making an http get request to get the html by passing the string to the pdf.create function and using the generated buffer to send the PDF file by email. This seems to process and send the file as an email attachment, however, when I try to open the file, I get an error message when the file is damaged.
code that convert html document to pdf: var options = { host: 'localhost', path: '/salesorder/' + orderid, port: '3000' }; http.request(options, function(response){ let buffer = ''; response.on('data', function (chunk) { buffer += chunk; }); response.on('end', function () { pdf.create(buffer, { directory: "tmp" }).toBuffer(function(err, newbuffer){ if (err){ reject(err); } if (Buffer.isBuffer(newbuffer)){ resolve(newbuffer); } else { reject(new Error('The pdf file could not be generated at this time. Please try again later.')); } }); }); }) .end(); code that sends the email: var transporter = nodemailer.createTransport({ service: 'gmail', host: this.hostname, auth: { user: this.smtpusername, pass: this.smtppassword } }); var mailOptions = { from: fromaddress,
I am using the html-pdf node.js package to perform the conversion. What am I missing here? I take the html that I get from the http.request method and I see the code generated if I print it using console.log. Now I notice that I do not see fillable text fields and shortcuts, so this is not like jquery processing.
user1790300
source share