Cordova plugins not working with Capacitor

I’m not sure how to get Cordova plugins working with Capacitor.

I am following this example ( but I am going to add some Capacitor plugins to it in order to use the camera.

Do the Cordova plugins below still work with Capacitor? I can’t get them to work at all. They work fine using cordova rather than Capacitor.
I have created project as folllows and it seems to copy them to the Capacitor android project ok.

ionic start myApp
cd myApp
npm install @capacitor/core @capacitor/cli
npx cap init
npm install pdfmake @ionic-native/file-opener @ionic-native/file 
npm install cordova-plugin-file-opener2
npm install cordova-plugin-file
npx cap sync
npx cap copy

*Writes code that is in link*

create myApp/www dir
copied index.html to myApp/www dir
npx cap add android
npx cap open android (opens android studio)
ionic capacitor run android
run in emulator from android studio

Fails on this line with no warning or error in console:
this.file.writeFile(this.file.dataDirectory, 'myletter.pdf', blob, { replace: true }).then(fileEntry => {


You don’t need a Cordova plugin to access the filesystem when using Capacitor, see its API:

I have tried to use the Capacitor Filesystem.writeFile but it does not accept a blob only string.
So I encoded my pdf as base64 and it writes ok, but it seems to be an invalid format when I open the file from the device.

I have been stuck on this for ages. Any suggestions?


const fileName = 'defectreport.pdf';
        try {
            path: fileName,
            data: this.pdfBase64,
            directory: FilesystemDirectory.Data,
            encoding: FilesystemEncoding.UTF8
          }).then((writeFileResult) => {
            console.log('File Written');
                directory: FilesystemDirectory.Data,
                path: fileName
            }).then((getUriResult) => {
                const path = getUriResult.uri;
      , 'application/pdf')
                .then(() => console.log('File is opened'))
                .catch(error => console.log('Error openening file', error));
            }, (error) => {
          console.log('writeFile complete');
        } catch (error) {
          console.error('Unable to write file', error);