In one project function for create pdf and download not work in another place. Why?

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 => {
   console.log("step 1 : " + this.file.externalRootDirectory);    
this.file.resolveDirectoryUrl(this.file.externalRootDirectory)
      .then(dirEntry => {
       console.log("step 2 : " + dirEntry);  
        this.file.getFile(dirEntry, 'paymentreceipt.pdf', { create: true })
          .then(fileEntry => {
           console.log("step 3 : " + fileEntry);  
            fileEntry.createWriter(writer => {
              writer.onwrite = () => {
                console.log("step 4 : " + fileEntry.toURL());
                this.fileOpener.open(fileEntry.toURL(), 'application/pdf')
                  .then(res => {
                   console.log("step 5 :  completed : " + res);
                   })
                  .catch(err => {
                  console.log("step 6 : error : " + err);
                   });
              }
              writer.write(buffer);
               console.log("step 7 : writing : " + 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();
      });

  });
 }

the Console result is shown as in chromium

step 1 : file:///storage/emulated/0/

step 2 : {"isFile":false,"isDirectory":true,"name":"","fullPath":"/","filesystem":"<FileSystem: sdcard>","nativeURL":"file:///storage/emulated/0/"}

step 3 : {"isFile":true,"isDirectory":false,"name":"paymentreceipt.pdf","fullPath":"/paymentreceipt.pdf","filesystem":"<FileSystem: sdcard>","nativeURL":"file:///storage/emulated/0/paymentreceipt.pdf"}

step 7 : writing : {}



In working code the console output is

step 1 : file:///storage/emulated/0/
step 2 : {"isFile":false,"isDirectory":true,"name":"","fullPath":"/","filesystem":"<FileSystem: sdcard>","nativeURL":"file:///storage/emulated/0/"}

step 3 : {"isFile":true,"isDirectory":false,"name":"paymentreceipt.pdf","fullPath":"/paymentreceipt.pdf","filesystem":"<FileSystem: sdcard>","nativeURL":"file:///storage/emulated/0/paymentreceipt.pdf"}
step 7 : writing : {}
step 4 : file:///storage/emulated/0/paymentreceipt.pdf
step 5 :  completed : "OK"

Here the Step 4 and Step 5 not working (in first case)

But in another project place it will not work without any error and open a functional PDF…
please any body help … I am looking this for 3 days :d

Thanks

Anes

what type of project created “super” or “blank” ?

Sorry I used already existing code . So don’t know the project is ‘super’ or ‘blank’

I can see my problem is no “paymentreceipt.pdf” file generated at all . It’s working on another demo project in my phone itself

Pls advise