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.55k stars 544 forks source link

How to change the page title and pdf title? #667

Open ysd-wilson opened 2 years ago

ysd-wilson commented 2 years ago

Currently the page title and pdf title use the end of url segment by default. How to change them? I have tried title tag in head but not working.

Screenshot 2022-03-21 at 10 58 14 AM

Here my code:

   pdf.create(html).toStream(function(err, stream){
      if (err) return res.end(err.stack)
      res.setHeader('Content-Type', 'application/pdf')
      res.setHeader('Content-Disposition', 'filename=my_filename.pdf')
      stream.pipe(res)
    });
dav-q commented 1 year ago

Currently the page title and pdf title use the end of url segment by default. How to change them? I have tried title tag in head but not working. Screenshot 2022-03-21 at 10 58 14 AM

Here my code:

   pdf.create(html).toStream(function(err, stream){
      if (err) return res.end(err.stack)
      res.setHeader('Content-Type', 'application/pdf')
      res.setHeader('Content-Disposition', 'filename=my_filename.pdf')
      stream.pipe(res)
    });

I have the same problem, did you find any solution?