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

120
Views
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
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!