Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

339
Views
Node JS how to wait Dom loaded then call function?

I'm using wkhtmltopdf to print my data and I load content from json file to html. I'm trying to do, loop through the array and pass data to variable and the table take data from variable to show and save pdf then clear variable write next item in array.

When I run js file, it generates pdf for each item but same loaded on html template and pdf.

Here is my loop the data and savePDF function.

let rawdata = fs.readFileSync('data.json');
let data = JSON.parse(rawdata);

async function pdfCreate() {

  let parcaNo = data1.oemCode;
  let uygunlukItems = data1.uygunluk;
  var params = {
    parcaNo: parcaNo,
    uygunlukItem: uygunlukItems
  };
  console.log(parcaNo);

  for (var i = 0, p = Promise.resolve(); i < data.length; i++) {
    parcaNo = data[i].oemCode;
    uygunlukItems = data[i].uygunluk
    console.log(data[i].oemCode)

    p.then(saveToPdf('catalog', path.resolve(__dirname, `./PDF/${parcaNo}.pdf`), params, () => {}));
    parcaNo = "",
      uygunlukItems = [];
  }

}

await pdfCreate();

Here is my json example :

Here is my json example :

How can I create pdf for each element ?

Thanks for your help!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!