Currently, I have the following script:
exportPDF(id) {
const options = {
filename: 'INV' + id + '.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: {
scale: 2, dpi: 300,
letterRendering: true,
useCORS: true
},
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
}
var element = document.getElementById('export-content');
var d = html2pdf().from(element).set(options).save();
const formData: FormData = new FormData();
formData.append('file', d);
// Service for uploading file to s3 bucket
this._uploadService.upload('invoice', formData).subscribe(res => {
console.log(res);
}, (error: any) => {
console.log(error, 'error');
});}
I need assistance in storing the generated pdf file to an S3 bucket and then sending it as an email attachment from S3 without storing any blob data in the database. I just want to store the S3 URL in the database. Any help would be appreciated.
While I found a solution by converting the blob string to a file, I am facing issues with storing the response string in a global variable for conversion and sending via an API call.
this.blobString: any;
html2pdf().from(element).set(options).toPdf().output('datauristring').then(function (res) {
this.blobString = res;
// Service for uploading file to s3 bucket
this._uploadService.upload('invoice', this.blobString).subscribe(res => {
console.log(res);
}, (error: any) => {
console.log(error, 'error');
});
});
console.log(this.blobString);
When checking the console, I see "undefined." How can I set Worker data globally?