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?
