'Why does not the data get displayed in the PDFs despite being loaded in the rows?
The highest three functions are defined in the actplan balance month export component .They help with calling the PDF export from the reporting component(an extern component).
public isReporting = false;
// Export pdf at pl-month-absolute level
public async exportActplanBalanceMonthPDFClick() {
this.isForReporting = false;
await this.exportActPlanBalanceMonthPDF({});
}
exportActplanBalanceMonthPDFClick(): the pdf is generated from its own component and is not launched from the reporting component.
/**
* Collect all calls
*/
private async setupDataForPdf() {
return new Promise<boolean>((resolve, reject) => {
this.isForReporting = true;
this.loadData((loadDataSuccess: boolean) => {
this.loadReportingMandantData((reportingSuccess: boolean) => {
this.renderExportTimeStamp();
// this.getActPlanBalanceMonthData();
return resolve(reportingSuccess);
});
// return resolve(loadDataSuccess);
});
});
}
setupDataForPdf(): it is launched from the reporting component and loads all of the data.
/**
* Share data with report-composition
*/
public async generatePdfForComposition(): Promise<any> {
console.log('ActPlanBalanceMonthExport - generatePdfForComposition');
await this.setupDataForPdf();
const res = await this.exportActPlanBalanceMonthPDF({});
return res;
}
generatePdfForComposition():When everything is in place, the PDF export is launched.
/**
* To export as pdf
*/
public exportActPlanBalanceMonthPDF(pdfObject) {
return new Promise<any>((resolve, reject) => {....
// Use here the pdf-autotable
pdf.autoTable(this.renderColumns, this.renderRows, options);
if (typeof pdf.putTotalPages === 'function') {
pdf.putTotalPages(totalPagesExp);
}
if (this.isForReporting === true) {
pdfObject.arrayBuffer = pdf.output('arraybuffer');
console.log('AB OBAB', pdfObject.arrayBuffer);
console.log('AB1', pdf.output('arraybuffer'));
return resolve(pdfObject.arrayBuffer);
} else {
pdf.save('Bilanzen_Monatsebene.pdf');
console.log('AB 2', pdf.output('arraybuffer'));
this.currentActPlanBalanceMonthExport.emit({excel: true});
return resolve({pdf});
}
});
}
exportActPlanBalanceMonthPDF(pdfObject):The export function successfully prints a PDF with all the necessary data. It works if called from the component it is in. The pdfObject parameter must contain a JS object which carries an array buffer(which is thrown into a function that generates the wanted PDF). This works per se. And everything is shown
If I call the export function from the reporting component(which is extern) nothing is shown although the data has successfully been loaded. Do you know what is going on that it doesn't work?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
