Add PDF title

This commit is contained in:
Pablo Bonilla 2021-08-10 18:22:01 -06:00
parent 6267ff5071
commit e5c679570a
No known key found for this signature in database
GPG Key ID: 46877262B8DE47E2
2 changed files with 11 additions and 5 deletions

View File

@ -28,7 +28,8 @@ export class DashboardAdminComponent implements OnInit {
const _reporteUsuarios = { usuarios_activos: 100, usuarios_bloqueados: 50 };
const _excelFinalData = [_reporteUsuarios];
exportAsExcelFile(_sheets, _excelFinalData, 'reporte_general');
const _fileName = 'reporte_general';
exportAsExcelFile(_sheets, _excelFinalData, _fileName);
}
exportReportesGeneralesAdministradorPDF(): void {
@ -47,7 +48,9 @@ export class DashboardAdminComponent implements OnInit {
const _headers = ['usuarios_activos', 'usuarios_bloqueados'];
const _docHeaders = createPDFTableHeaders(_headers);
const _fileName = 'reporte_general';
const _docTitle = 'Reportes Generales de la Aplicación';
generatePDFTable(doc, _docData, _docHeaders);
generatePDFTable(doc, _docData, _docHeaders, _fileName, _docTitle);
}
}

View File

@ -28,8 +28,11 @@ export const createPDFTableHeaders = (keys: any): any[] => {
return result;
};
export const generatePDFTable = (doc: jsPDF, _docData: any, _docHeaders: string[]): void => {
doc.table(1, 1, _docData, _docHeaders, { autoSize: true });
const generatedFileName = generateFileName('reporte_general', PDF_EXTENSION);
export const generatePDFTable = (doc: jsPDF, _docData: any, _docHeaders: string[], _fileName: string, _docTitle: string): void => {
doc.setFontSize(20);
doc.setFont('helvetica', 'bold');
doc.text(_docTitle, 20, 20);
doc.table(20, 30, _docData, _docHeaders, { autoSize: true });
const generatedFileName = generateFileName(_fileName, PDF_EXTENSION);
doc.save(generatedFileName);
};