Ionic 4 + vue + capacitor. Filesystem writeFile. Base64 file decode error

Hi there!
First of all thx for reading this.

So I have this piece of code where I’m trying to save a pdf file from my API, which is encoded in base 64

downloadFile() {
      let fileTo = null;
      this.getProjectPd.project.files.forEach(file => {
        if (file.id == this.getProjectPd.idDocument) fileTo = file;
      });
      let link = document.createElement("a");
      link.href = fileTo.file;
      link.download = fileTo.name;
      link.target = "_blank";
      link.click();

      //Everything is written above not really important, it's related to the browser version
      // I have issues for the code below

      console.log( atob(fileTo.file.substr(28)) )
   
      try {
        Filesystem.writeFile({
          path: `test1/${fileTo.name}`,
          data: atob(fileTo.file.substr(28)),
          directory: FilesystemDirectory.Documents,
          encoding: FilesystemEncoding.UTF8
        });
      } catch (e) {
        console.error("Unable to write file", e);
      }
    },

so here is my attempt to encode file and save it

data: atob(fileTo.file.substr(28)),

this is result

and this what I get in the console

P.S the question is no longer relevant. Just need to delete encoding: FilesystemEncoding.UTF8 And pass to data: base64 string