Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

341
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda