|
@ -5,6 +5,7 @@ import { CookieService } from "ngx-cookie-service"; |
|
|
import * as pdfMake from "pdfmake/build/pdfmake"; |
|
|
import * as pdfMake from "pdfmake/build/pdfmake"; |
|
|
import { GenerateLetterService } from "./generate-letter.service"; |
|
|
import { GenerateLetterService } from "./generate-letter.service"; |
|
|
import { DomSanitizer } from '@angular/platform-browser'; |
|
|
import { DomSanitizer } from '@angular/platform-browser'; |
|
|
|
|
|
import { logoBase64 } from "src/constants/constants"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pdfFonts = require("pdfmake/build/vfs_fonts.js"); |
|
|
var pdfFonts = require("pdfmake/build/vfs_fonts.js"); |
|
@ -24,7 +25,10 @@ export class GenerateLetterComponent implements OnInit { |
|
|
printPDF: boolean = false; |
|
|
printPDF: boolean = false; |
|
|
level: string = ""; |
|
|
level: string = ""; |
|
|
downloadStatus:any = ''; |
|
|
downloadStatus:any = ''; |
|
|
logoPath:any = 'assets/images/logo-indian.png'; |
|
|
|
|
|
|
|
|
logoPath:any = 'assets/images/bajaj_logo_ai_small.png'; |
|
|
|
|
|
interval:any; |
|
|
|
|
|
//logoPath:any = logoBase64;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ViewChild("pdfTable", { static: false }) pdfTable: ElementRef | undefined; |
|
|
@ViewChild("pdfTable", { static: false }) pdfTable: ElementRef | undefined; |
|
|
|
|
|
|
|
@ -140,24 +144,27 @@ export class GenerateLetterComponent implements OnInit { |
|
|
*/ |
|
|
*/ |
|
|
downloadPDF() { |
|
|
downloadPDF() { |
|
|
this.printPDF = true; |
|
|
this.printPDF = true; |
|
|
const doc = new jsPDF(); |
|
|
|
|
|
const pdfTable: any = |
|
|
|
|
|
this.level === "L3" |
|
|
|
|
|
? this.generateLetterL3.nativeElement |
|
|
|
|
|
: this.generateLetterL0L1.nativeElement; |
|
|
|
|
|
|
|
|
|
|
|
//get table html
|
|
|
|
|
|
//const pdfTable = this.content.nativeElement;
|
|
|
|
|
|
//html to pdf format
|
|
|
|
|
|
var html = htmlToPdfmake(pdfTable.innerHTML); |
|
|
|
|
|
const documentDefinition = { content: [html], defaultStyle: { |
|
|
|
|
|
fontSize: 10, |
|
|
|
|
|
bold: true |
|
|
|
|
|
}}; |
|
|
|
|
|
pdfMake.createPdf(documentDefinition).download(); |
|
|
|
|
|
this.printPDF = false; |
|
|
|
|
|
this.downloadPDFlevel3 = false; |
|
|
|
|
|
this.downloadPDFlevel0 = false; |
|
|
|
|
|
|
|
|
this.logoPath = logoBase64; |
|
|
|
|
|
this.interval = setInterval(() => { |
|
|
|
|
|
const doc = new jsPDF(); |
|
|
|
|
|
const pdfTable: any = |
|
|
|
|
|
this.level === "L3" |
|
|
|
|
|
? this.generateLetterL3.nativeElement |
|
|
|
|
|
: this.generateLetterL0L1.nativeElement; |
|
|
|
|
|
//html to pdf format
|
|
|
|
|
|
var html = htmlToPdfmake(pdfTable.innerHTML); |
|
|
|
|
|
const documentDefinition = { content: [html], defaultStyle: { |
|
|
|
|
|
fontSize: 10, |
|
|
|
|
|
bold: true |
|
|
|
|
|
}}; |
|
|
|
|
|
pdfMake.createPdf(documentDefinition).download(); |
|
|
|
|
|
this.printPDF = false; |
|
|
|
|
|
this.downloadPDFlevel3 = false; |
|
|
|
|
|
this.downloadPDFlevel0 = false; |
|
|
|
|
|
clearInterval(this.interval); |
|
|
|
|
|
}, 500); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// doc.save("output.pdf");
|
|
|
// doc.save("output.pdf");
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|