Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

340
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda