Nicholaiii / handlebars-pdf

Render PDF from handlebars
7 stars 4 forks source link

Separate HTML file and give path to that HTML #2

Closed shivampandey2021 closed 5 years ago

shivampandey2021 commented 6 years ago

How can I separate HTML file and give path to that HTML ?

Nicholaiii commented 6 years ago

Are you looking to use an HTML file instead of just a text template?

const fs = require('fs')

let document = {
  template: fs.readFileSync('document.html', 'utf8'),
  context: {
    msg: 'Hello world'
  },
  path: "./test-"+Math.random()+".pdf"
}

This assumes your file is saved in utf8

shivampandey2021 commented 6 years ago

Thanks for your response.

After using a separate html file the content does not fit to pdf page When I am running it on PRODUCTION. The width of the content is more than the pdf page and content got cut from the right side. Any help?