marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 545 forks source link

get the filepath outside the .toFile() #648

Open kemoboy opened 2 years ago

kemoboy commented 2 years ago

I have this code

var pdfPath = '';

pdf.create(pdfTemplate('some name goes here'), {})
    .toFile(`./test/${req.body.propertyType}.pdf`, function(err, res) {
        if (err) {
            return console.log(err)
        } else {
            // console.log(res.filename) //works returns res.filename
            pdfPath = res.filename 
        }
    })

console.log(pdfPath) //not working not returning res.filname

How can I get the res.filename to use it somewhere else?

Thanks!
oscarcornejo commented 2 years ago

Same problem! :(