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

121
Vistas
How do I control the time the settimeout takes to load an array buffer completely?

enter image description here

I need an array buffer(that can be used to generate a PDF) that has 137618 bytes. In the exportFcBwaPDF function, when called in component A,the array buffer is loaded completely and has the values it is supposed to have.

public exportFcBwaPDF(pdfObject) {
...
 if (this.isForReporting === true){

      pdfObject.arrayBuffer = pdf.output('arraybuffer');
      console.log('AB OBAB' ,  pdfObject.arrayBuffer);
      console.log('AB FC1' ,  pdf.output('arraybuffer'));
      return pdfObject.arrayBuffer;
    }else {
      pdf.save('FC-BWA.pdf');
      console.log('AB FCBWA 2', pdf.output('arraybuffer'));
      this.currentFcBwaExport.emit({excel: true});
    }

}

generateExternFcBwaPDF() is a function that is supposed to return the said arraybuffer after 15 seconds because some data needs some time to be completely loaded in order to be printed on a PDF. Regarding the 2nd function: everything from the line where ' let fcBwaPdfObject = {arrayBuffer: ''};' is seen is important everything else can be ignored.

 public  generateExternFcBwaPDF(){
    // function (JS object, parameter) ; object = {key:value};setTimeout(function (JS object, parameter),time)
    this.loadData();
    this.getCurrentYear();
    this.loadMandantData();
    this.renderExportTimeStamp();
    this.sortByProperty('nr.');
    this.loadMandantData();
    let fcBwaPdfObject = {arrayBuffer: ''};
    setTimeout(this.exportFcBwaPDF(fcBwaPdfObject), 15000);
    console.log('Generate AB', fcBwaPdfObject.arrayBuffer);
return fcBwaPdfObject.arrayBuffer;
  }

Both the 2 functions have been coded inside component A. .

  const externExp =  new FcBwaExportComponent(this.navService, this.changeColorService, this.userAreaService, this.fcBwaService, this.renderer, this.element, this.document);
   externExp.isForReporting = true;
externExp.generateExternFcBwaPDF();

I call the generateExternFcBwaPDF function inside component B and the array buffer is not what I am looking for. The arraybuffer with 3438 bytes finishes too early. What do I do wrong? Can anyone explain why it doesn't work correctly? enter image description here

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