// I am trying to show logo(Image) into PDF file but im not able to get image into PDF Please help //me
import { PhotoViewer } from ‘@ionic-native/photo-viewer’; // import in html.ts
createPdf() {
var result =this.rowsitems.map(function(item)
{
return [item.item, item.qty, item.priceINR,item.lineTotalINR];
});
var docDefinition =
{
content: [
**// Tried immediate below both method but image is not showing in PDF file **
this.photoViewer.show(this.file.applicationDirectory + img,title,{share: true}),
// this.photoViewer.show(’…/assets/imgs/Deepcleanlogo-1.png’),
{ text: this.PDFrows.invoice, style: ‘header’,alignment: ‘right’},
{ text: this.PDFrows.address, style: ‘address’},
];
this.pdfObj=pdfMake.createPdf(docDefinition);
//PDF Download
if (this.plt.is(‘cordova’)) {
this.pdfObj.getBuffer((buffer) => {
var blob = new Blob([buffer], { type: 'application/pdf' });
// Save the PDF to the data Directory of our App
this.file.writeFile(this.file.dataDirectory, 'myletter.pdf', blob, { replace: true }).then(fileEntry => {
// Open the PDf with the correct OS tools
this.fileOpener.open(this.file.dataDirectory + 'myletter.pdf', 'application/pdf');
})
});
} else {
// On a browser simply use download!
this.pdfObj.download();
}
}