I was try to get the height from html. I render the html using ejs because I need to insert a data into the html and then the result from ejs was processing with jsdom library.
I was write <script> in my html/ejs file to get the document.documentElement.getBoundingClientRect().height. But the result is return 0. And when I try to run document.body its return HTMLBodyElement {}. I placed the <script> inside the <body>. I assume when the document.body was not return any value, then something mistake there.
here's my code :
await new Promise(function (resolve, reject) {
ejs.renderFile(path.join(__basedir, '/views/', 'pdf.ejs'), {
title: fileNameGenerate,
...
}, (err, data) => {
if (err) {
console.error(err)
reject(err);
done(err)
} else {
const dom = new JSDOM(`${data}`, {runScripts: "dangerously"});
...
What's make the document.body not returning any value ?
PLease ask me if this informatiions is still not enough to solve that problem