Dear Friends,
in one of my sample code the function works for creation and download of PDF as follows
createPdf(epayTransID,status,ReceiptDate,TaxPeriod,TotAmount,BankRefNo) {
var docDefinition = {
content: [
{ text: 'Payment Receipt', style: 'header' },
{ text: new Date().toTimeString(), alignment: 'right' },
{ text: 'Transaction ID', style: 'subheader' },
{ text: epayTransID },
{ text: 'Status', style: 'subheader' },
{ text: status },
{ text: 'Receipt Date', style: 'subheader'},
{ text: ReceiptDate },
{ text: 'Tax Period', style: 'subheader'},
{ text: TaxPeriod },
{ text: 'Total Amount', style: 'subheader'},
{ text: TotAmount},
{ text: 'Bank Reference no', style: 'subheader'},
{ text: BankRefNo},
],
styles: {
header: {
fontSize: 18,
bold: true,
},
subheader: {
fontSize: 14,
bold: true,
margin: [0, 15, 0, 0]
},
story: {
italic: true,
alignment: 'center',
width: '50%',
}
}
}
this.pdfObj = pdfMake.createPdf(docDefinition).getBlob(buffer => {
this.file.resolveDirectoryUrl(this.file.externalRootDirectory)
.then(dirEntry => {
this.file.getFile(dirEntry, 'paymentreceipt.pdf', { create: true })
.then(fileEntry => {
fileEntry.createWriter(writer => {
writer.onwrite = () => {
this.fileOpener.open(fileEntry.toURL(), 'application/pdf')
.then(res => { })
.catch(err => {
});
}
writer.write(buffer);
})
})
.catch(err => {
//const alert = this.alertCtrl.create({ message: err, buttons: ['Ok'] });
//alert.present();
});
})
.catch(err => {
//const alert = this.alertCtrl.create({ message: err, buttons: ['Ok'] });
//alert.present();
});
});
}
but in another project place it will not work without any error
please any body help … I am looking this for 3 days :d
Thanks
Anes